version 1.172, 2004/10/04 12:57:19
|
version 1.176, 2004/10/06 13:02:56
|
Line 32 from Acquisition import Implicit
|
Line 32 from Acquisition import Implicit
|
from ECHO_helpers import displayTypes |
from ECHO_helpers import displayTypes |
import urllib |
import urllib |
import time |
import time |
|
from Ft.Xml.Domlette import NonvalidatingReader |
|
from Ft.Xml.Domlette import PrettyPrint |
|
from Ft.Xml import EMPTY_NAMESPACE |
|
|
|
import Ft.Xml.XPath |
|
import cStringIO |
|
|
try: |
try: |
from psycopg import libpq |
from psycopg import libpq |
Line 3520 class ECHO_root(Folder,Persistent,Implic
|
Line 3526 class ECHO_root(Folder,Persistent,Implic
|
|
|
def xml2html(self,str,quote="yes"): |
def xml2html(self,str,quote="yes"): |
"""link2html fuer VLP muss hier noch raus""" |
"""link2html fuer VLP muss hier noch raus""" |
#print str |
|
|
|
if str: |
if str: |
if quote=="yes2": |
if quote=="yes2": |
str=re.sub("\&","&",str) |
str=re.sub("\&","&",str) |
dom=xml.dom.minidom.parseString(str) |
#dom=xml.dom.minidom.parseString(str) |
links=dom.getElementsByTagName("link") |
dom = NonvalidatingReader.parseString(str,"http://www.mpiwg-berlin.mpg.de/") |
|
#links=dom.getElementsByTagName("link") |
|
links=Ft.Xml.XPath.Evaluate(".//link", contextNode=dom) |
for link in links: |
for link in links: |
link.tagName="a" |
#link.tagName="a" |
ref=link.getAttribute("ref") |
|
pn=link.getAttribute("page") |
|
|
|
|
ref=link.getAttributeNS(EMPTY_NAMESPACE,"ref") |
|
pn=link.getAttributeNS(EMPTY_NAMESPACE,"page") |
|
|
|
cns=link.childNodes[0:] |
|
|
|
newLink=dom.createElementNS(EMPTY_NAMESPACE,"a") |
|
for x in cns: |
|
newLink.appendChild(x) |
|
|
|
|
|
|
|
link.parentNode.replaceChild(newLink,link) |
if self.checkRef(ref): |
if self.checkRef(ref): |
if pn: |
if pn: |
link.setAttribute("href",self.aq_parent.absolute_url()+"/vlp_coll?id="+ref+"&p="+pn) |
newLink.setAttributeNS(EMPTY_NAMESPACE,"href",self.aq_parent.absolute_url()+"/vlp_coll?id="+ref+"&p="+pn) |
else: |
else: |
link.setAttribute("href",self.aq_parent.absolute_url()+"/vlp_coll?id="+ref) |
newLink.setAttributeNS(EMPTY_NAMESPACE,"href",self.aq_parent.absolute_url()+"/vlp_coll?id="+ref) |
|
|
str= dom.toxml() |
|
|
|
|
#str= dom.toxml('utf-8') |
|
buf = cStringIO.StringIO() |
|
PrettyPrint(dom, stream=buf, encoding='UTF-8') |
|
str = buf.getvalue() |
|
buf.close() |
|
#str=PrettyPrint(dom.documentElement,encoding='UTF-8') |
#print link.toxml('utf-8') |
#print link.toxml('utf-8') |
|
#print type(str) |
retStr=regexpPage.search(str) |
retStr=regexpPage.search(str) |
|
try: # hack warum fehtl manchmal page?? |
return retStr.group(1) |
return retStr.group(1) |
|
except: |
|
return str |
return "" |
return "" |
|
|
def checkRef(self,ref): |
def checkRef(self,ref): |
dbs={'vl_literature':'AND CD LIKE \'%lise%\'','vl_technology':'','vl_people':'','vl_sites':''} |
if ref[0:3]=='lit': |
|
if len(self.library_data({ 'id':ref}))>0: |
|
return 1 |
|
try: |
|
if ref[0:7]=="tec_cat": |
|
return 1 |
|
except: |
|
"""nothing""" |
|
|
|
dbs={'vl_technology':'','vl_people':'','vl_sites':''} |
res=None |
res=None |
for db in dbs.keys(): |
for db in dbs.keys(): |
|
|
res=res or self.search(var=str("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 |
return res |
|
|