--- ECHO_content/ECHO_collection.py 2004/02/09 11:45:46 1.13 +++ ECHO_content/ECHO_collection.py 2004/02/11 17:45:29 1.14 @@ -10,6 +10,7 @@ class ECHO_externalLink contains informa """ import string +import re import OFS.Image from types import * from OFS.Image import Image @@ -24,6 +25,7 @@ from Products.PageTemplates.PageTemplate from Globals import Persistent from Acquisition import Implicit from pyPgSQL import libpq +import xml.dom.minidom import urllib import xml.dom.minidom @@ -652,9 +654,68 @@ class ECHO_root(Folder,Persistent,Implic self.id = id self.title=title + def deleteSpace(self,str): + """delete space at the end of a line""" + if str[len(str)-1]==" ": + return str[0:len(str)-1] + else: + return str + + + + # zusaetliche methoden fuer das vlp muessen in ein eigenes produkt + + def formatAscii(self,str,url=None): + """ersetze ascii umbrueche durch
""" + #url=None + if url: + + retStr="" + words=str.split("\n") + + for word in words: + strUrl=url%word + print "str",strUrl + retStr+="""%s
"""%(strUrl,word) + str=retStr + if str: + return re.sub(r"[\n]","
",str) + else: + return "" + + def link2html(self,str): + """link2html fuer VLP muss hier noch raus""" + if str: + print str + str=re.sub("\&","&",str) + dom=xml.dom.minidom.parseString(""+str+"") + links=dom.getElementsByTagName("link") + + print "link",links + for link in links: + link.tagName="a" + ref=link.getAttribute("ref") + if self.checkRef(ref): + link.setAttribute("href",self.aq_parent.absolute_url()+"/vlp_coll?id="+ref) + + return dom.toxml('utf-8') + return "" + + + def checkRef(self,ref): + dbs={'vl_literature':'AND CD LIKE \'%lise%\'','vl_technology':'','vl_people':''} + res=None + for db in dbs.keys(): + #print ref,"select reference from %s where reference =\'%s\' %s"%(db,ref,dbs[db]) + + res=res or self.search(var=str("select reference from %s where reference =\'%s\' %s"%(db,ref,dbs[db]))) + return res + + #Ende Methode fuer vlp + def PgQuoteString(self,string): """Quote string""" - print "PG",string + #print "PG",string return libpq.PgQuoteString(string) def getPartners(self):