version 1.299, 2008/12/04 21:27:00
|
version 1.311, 2011/11/03 11:05:25
|
Line 1
|
Line 1
|
"""New version of the product started February, 8th. Without scientific classification, use content-type for further classification.""" |
"""New version of the produc started February, 8th. Without scientific classification, use content-type for further classification.""" |
"""Echo collection provides the classes for the ECHO content web-site. |
"""Echo collection provides the classes for the ECHO content web-site. |
|
|
class ECHO_collection is the basis class for an ECHO collection. |
class ECHO_collection is the basis class for an ECHO collection. |
Line 40 from Globals import Persistent, package_
|
Line 40 from Globals import Persistent, package_
|
from Acquisition import Implicit |
from Acquisition import Implicit |
from Products.ZCatalog.CatalogPathAwareness import CatalogAware |
from Products.ZCatalog.CatalogPathAwareness import CatalogAware |
from Products.ZCTextIndex.ZCTextIndex import manage_addLexicon |
from Products.ZCTextIndex.ZCTextIndex import manage_addLexicon |
|
try: |
from Products.MetaDataProvider.MetaDataClient import MetaDataClient |
from Products.MetaDataProvider.MetaDataClient import MetaDataClient |
|
except: |
|
print "no metadataclient" |
import urllib |
import urllib |
import urllib2 |
import urllib2 |
import cgi |
import cgi |
Line 54 import Ft.Xml.XPath
|
Line 57 import Ft.Xml.XPath
|
import cStringIO |
import cStringIO |
|
|
import sys |
import sys |
|
import logging |
|
|
try: |
try: |
from psycopg import libpq |
from psycopg import libpq |
Line 103 def setECHO_collectionInformation(self,t
|
Line 107 def setECHO_collectionInformation(self,t
|
self.weight=weight |
self.weight=weight |
|
|
import ECHO_resource |
import ECHO_resource |
|
from ECHO_resource import manage_addECHO_resource |
|
|
class ECHO_resource(ECHO_resource.ECHO_resource): |
class ECHO_resource(ECHO_resource.ECHO_resource): |
"""depricated use class in ECHO_resource.py""" |
"""depricated use class in ECHO_resource.py""" |
Line 376 class ECHO_fullText(ZopePageTemplate,ECH
|
Line 381 class ECHO_fullText(ZopePageTemplate,ECH
|
try: |
try: |
dom=xml.dom.minidom.parseString(self()) |
dom=xml.dom.minidom.parseString(self()) |
except: |
except: |
dom=xml.dom.minidom.parseString(self().encode('latin-1')) |
dom=xml.dom.minidom.parseString(self.utf8ify(self())) |
pages=dom.getElementsByTagName('page') |
pages=dom.getElementsByTagName('page') |
|
|
return pages[int(nr)-1].toxml() |
return pages[int(nr)-1].toxml() |
Line 697 class ECHO_collection(CatalogAware, Fold
|
Line 702 class ECHO_collection(CatalogAware, Fold
|
|
|
path="/mpiwg/online/permanent/shipbuilding" |
path="/mpiwg/online/permanent/shipbuilding" |
|
|
|
def getSection(self, crumbs=None): |
|
"""returns the current section name""" |
|
# use breadcrumbs if available |
|
if crumbs is not None and len(crumbs) > 0: |
|
return crumbs[0][2].getId() |
|
|
|
p = self |
|
|
|
sec = None |
|
# descend parents to the root (and remember the last id) |
|
while p is not None and p.meta_type != 'ECHO_root' and p.meta_type!='ECHO_main' and p.meta_type!='ECHO_nav': |
|
sec = p.getId() |
|
p = p.aq_parent |
|
|
|
return sec |
|
|
|
def getSubSection(self, crumbs=None): |
|
"""returns the current subsection name""" |
|
# use breadcrumbs if available |
|
if crumbs is not None and len(crumbs) > 1: |
|
return crumbs[1][2].getId() |
|
|
|
p = self |
|
sec = None |
|
subsec = None |
|
# descend parents to the root (and remember the last id) |
|
while p is not None and p.meta_type != 'ECHO_root' and p.meta_type!='ECHO_main' and p.meta_type!='ECHO_nav': |
|
subsec = sec |
|
sec = p.getId() |
|
p = p.aq_parent |
|
|
|
return subsec |
|
|
|
|
def exportImportObjects_html(self,RESPONSE): |
def exportImportObjects_html(self,RESPONSE): |
"""ImportObject""" |
"""ImportObject""" |
Line 718 class ECHO_collection(CatalogAware, Fold
|
Line 756 class ECHO_collection(CatalogAware, Fold
|
ret=None |
ret=None |
|
|
for name in zf.namelist(): |
for name in zf.namelist(): |
fn=tempfile.mkstemp()[1] |
ds,fn=tempfile.mkstemp() |
tf=file(fn,"w") |
tf=file(fn,"w") |
x=zf.read(name) |
x=zf.read(name) |
tf.write(x) |
tf.write(x) |
Line 729 class ECHO_collection(CatalogAware, Fold
|
Line 767 class ECHO_collection(CatalogAware, Fold
|
if not ret: |
if not ret: |
ret="" |
ret="" |
ret+="Cannot import: %s (Already existing?)<br>"%name |
ret+="Cannot import: %s (Already existing?)<br>"%name |
|
os.close(ds) |
os.remove(fn) |
os.remove(fn) |
|
|
|
zf.close() |
|
|
if ret: |
if ret: |
return """<html><body>%s</body></html>"""%ret |
return """<html><body>%s</body></html>"""%ret |
if RESPONSE: |
if RESPONSE: |
Line 849 class ECHO_collection(CatalogAware, Fold
|
Line 890 class ECHO_collection(CatalogAware, Fold
|
if not urn: |
if not urn: |
urn=self.absolute_url() |
urn=self.absolute_url() |
|
|
li="""<RDF:li RDF:resource="%s" />\n""" |
li="""<rdf:li rdf:resource="%s" />\n""" |
|
|
|
|
for content in contents: |
for content in contents: |
|
try: |
ret+=content[1].getRDF()+"\n" |
ret+=content[1].getRDF()+"\n" |
|
except: |
ret+="""<RDF:Seq RDF:about="%s">\n"""%urn |
logging.error("getrdf: "+repr(content[1].getRDF())) |
|
try: |
|
ret+=self.unicodify(content[1].getRDF())+"\n" |
|
except: |
|
logging.error("--still cannot do it") |
|
ret+=repr(content[1].getRDF())+"\n" |
|
ret+="""<rdf:Seq rdf:about="%s">\n"""%urn |
for content in contents: |
for content in contents: |
nurn=content[1].absolute_url() |
nurn=content[1].absolute_url() |
ret+=li%nurn |
ret+=li%nurn |
return ret+"</RDF:Seq>" |
return ret+"</rdf:Seq>" |
|
|
|
|
|
|
Line 989 class ECHO_collection(CatalogAware, Fold
|
Line 1037 class ECHO_collection(CatalogAware, Fold
|
pass |
pass |
return ret |
return ret |
|
|
def importCollection(self,path=None,RESPONSE=None): |
def importCollection(self,path=None,viewerUrl=None,metaDataUrl=None,replacePathPermanent=None,replacePathExperimental=None,RESPONSE=None): |
"""liest verzeichnisse aus dem pfad und legt sie dann als objekte in den ordner""" |
"""liest verzeichnisse aus dem pfad und legt sie dann als objekte in den ordner""" |
|
|
if path is None: |
if path is None: |
Line 1002 class ECHO_collection(CatalogAware, Fold
|
Line 1050 class ECHO_collection(CatalogAware, Fold
|
|
|
if fileName: |
if fileName: |
|
|
tempPath=re.sub("/mpiwg/online","",path) |
if (replacePathExperimental and replacePathExperimental!=''): |
link="http://echo.mpiwg-berlin.mpg.de/zogilib_book?fn="+tempPath+"/"+fileName+"/pageimg" |
path=re.sub(replacePathExperimental,"/mpiwg/online/experimental",path) |
|
|
metalink=self.path+"/"+fileName+"/index.meta" |
if (replacePathPermanent and replacePathPermanent!=''): |
|
path=re.sub(replacePathPermanent,"/mpiwg/online/permanent",path) |
|
|
|
link=viewerUrl%(path+"/"+fileName+"/pageimg") |
|
|
|
metalink=metaDataUrl+"/"+path+"/"+fileName+"/index.meta" |
try: |
try: |
|
|
#link="http://nausikaa2.mpiwg-berlin.mpg.de/cgi-bin/toc/toc.x.cgi?dir="+fileName+"&step=thumb" |
#link="http://nausikaa2.mpiwg-berlin.mpg.de/cgi-bin/toc/toc.x.cgi?dir="+fileName+"&step=thumb" |
|
|
newObj=ECHO_resource(fileName,link,metalink,fileName,fileName,fileName,'generated','book','','','','','','') |
newObj=ECHO_resource(fileName,link,metalink,fileName,fileName,fileName,'','book','','','','','','') |
self._setObject(fileName,newObj) |
self._setObject(fileName,newObj) |
|
|
genObj=getattr(self,fileName) |
genObj=getattr(self,fileName) |
Line 1453 class ECHO_collection(CatalogAware, Fold
|
Line 1506 class ECHO_collection(CatalogAware, Fold
|
|
|
def showOverview(self): |
def showOverview(self): |
"""overview""" |
"""overview""" |
|
# ECHO_overview.html template for this instance |
if 'ECHO_overview.html' in self.__dict__.keys(): |
if 'ECHO_overview.html' in self.__dict__.keys(): |
return getattr(self,'ECHO_overview.html')() |
return getattr(self,'ECHO_overview.html')() |
|
|
|
# ECHO_overview_main template in path |
|
if hasattr(self, 'ECHO_overview_main'): |
|
return getattr(self, 'ECHO_overview_main')() |
|
|
|
# template from product |
pt=zptFile(self, 'zpt/ECHO_content_overview.zpt') |
pt=zptFile(self, 'zpt/ECHO_content_overview.zpt') |
return pt() |
return pt() |
|
|
Line 1607 class ECHO_group(ECHO_collection):
|
Line 1667 class ECHO_group(ECHO_collection):
|
|
|
if not urn: |
if not urn: |
urn=self.absolute_url() |
urn=self.absolute_url() |
li="""<RDF:li RDF:resource="%s" />\n""" |
li="""<rdf:li rdf:resource="%s" />\n""" |
|
|
|
|
for content in contents: |
for content in contents: |
ret+=content[1].getRDF()+"\n" |
ret+=self.unicodify(content[1].getRDF())+"\n" |
|
|
ret+="""<RDF:Seq RDF:about="%s">\n"""%urn |
ret+="""<rdf:Seq rdf:about="%s">\n"""%urn |
for content in contents: |
for content in contents: |
nurn=content[1].absolute_url() |
nurn=content[1].absolute_url() |
ret+=li%nurn |
ret+=li%nurn |
return ret+"</RDF:Seq>" |
return ret+"</rdf:Seq>" |
|
|
def index_html(self): |
def index_html(self): |
"""standard page""" |
"""standard page""" |
Line 1801 class ECHO_userFolder(UserFolder):
|
Line 1861 class ECHO_userFolder(UserFolder):
|
return 1 |
return 1 |
return 0 |
return 0 |
|
|
Globals.default__class_init__(ECHO_userFolder) |
# ROC: problem with 2.12 |
|
#Globals.default__class_init__(ECHO_userFolder) |
|
|
|
|
|
|
Line 1876 class ECHO_root(Folder,Persistent,Implic
|
Line 1937 class ECHO_root(Folder,Persistent,Implic
|
) |
) |
|
|
|
|
|
|
|
|
def getECHORootURL(self): |
def getECHORootURL(self): |
return self.absolute_url() |
return self.absolute_url() |
|
|
Line 2052 class ECHO_root(Folder,Persistent,Implic
|
Line 2115 class ECHO_root(Folder,Persistent,Implic
|
global key |
global key |
global value |
global value |
seq="" |
seq="" |
if name=="RDF:Seq": |
if name=="rdf:Seq": |
key=attrs.get('RDF:about') |
key=attrs.get('rdf:about') |
try: # teste ob liste |
try: # teste ob liste |
x=seqs[key][0] |
x=seqs[key][0] |
except: |
except: |
Line 2061 class ECHO_root(Folder,Persistent,Implic
|
Line 2124 class ECHO_root(Folder,Persistent,Implic
|
seqs[key]=[] |
seqs[key]=[] |
|
|
|
|
elif name=="RDF:Description": |
elif name=="rdf:Description": |
key=attrs.get('RDF:about') |
key=attrs.get('rdf:about') |
|
|
|
|
elif name=="RDF:li": |
elif name=="rdf:li": |
name=attrs.get('RDF:resource') |
name=attrs.get('rdf:resource') |
seqs[key].append(name) |
seqs[key].append(name) |
|
|
elif name=="ECHONAVIGATION:type": |
elif name=="echonavigation:type": |
value="type" |
value="type" |
|
|
elif name=="ECHONAVIGATION:name": |
elif name=="echonavigation:name": |
value="name" |
value="name" |
elif name=="ECHONAVIGATION:linkClickable": |
elif name=="echonavigation:linkClickable": |
value="linkClickable" |
value="linkClickable" |
|
|
def end_element(name): |
def end_element(name): |
Line 2155 class ECHO_root(Folder,Persistent,Implic
|
Line 2218 class ECHO_root(Folder,Persistent,Implic
|
|
|
ret=getRDFDescription(self,self.absolute_url(),urn=urn) |
ret=getRDFDescription(self,self.absolute_url(),urn=urn) |
|
|
li="""<RDF:li RDF:resource="%s" />\n""" |
li="""<rdf:li rdf:resource="%s" />\n""" |
|
|
|
|
for content in contents: |
for content in contents: |
ret+=content[1].getRDF()+"\n" |
ret+=content[1].getRDF()+"\n" |
|
|
ret+="""<RDF:Seq RDF:about="%s">\n"""%urn |
ret+="""<rdf:Seq rdf:about="%s">\n"""%urn |
for content in contents: |
for content in contents: |
nurn=content[1].absolute_url() |
nurn=content[1].absolute_url() |
ret+=li%nurn |
ret+=li%nurn |
return ret+"</RDF:Seq>" |
return ret+"</rdf:Seq>" |
|
|
|
|
def showContent(self,path): |
def showContent(self,path): |
Line 2194 class ECHO_root(Folder,Persistent,Implic
|
Line 2257 class ECHO_root(Folder,Persistent,Implic
|
"""ret attribute if existing""" |
"""ret attribute if existing""" |
try: |
try: |
|
|
return getattr(found,field)#.decode('utf-8','ignore') |
|
|
return getattr(found,field)#.decode('ascii','ignore') |
|
|
|
|
|
|
except: |
except: |
logging.error("can't: decode: %s"%repr(field)) |
logging.error("can't: decode: %s"%repr(field)) |
logging.error(" %s %s"%(sys.exc_info()[0],sys.exc_info()[1])) |
logging.error(" %s %s"%(sys.exc_info()[0],sys.exc_info()[1])) |
Line 2546 class ECHO_root(Folder,Persistent,Implic
|
Line 2613 class ECHO_root(Folder,Persistent,Implic
|
|
|
ret="""<html><body><h2>Resources in ECHO</h3>""" |
ret="""<html><body><h2>Resources in ECHO</h3>""" |
|
|
resources = self.ZopeFind(self,obj_metatypes=['ECHO_resource'],search_sub=1) |
resources = self.ZopeFind(self,obj_metatypes=['ECHO_resource','VLP_resource'],search_sub=1) |
ret+="""<h3>Found %i resources</h3>"""%len(resources) |
ret+="""<h3>Found %i resources</h3>"""%len(resources) |
resources.sort(sortHTML) |
resources.sort(sortHTML) |
for resource in resources: |
for resource in resources: |
Line 2572 class ECHO_root(Folder,Persistent,Implic
|
Line 2639 class ECHO_root(Folder,Persistent,Implic
|
"""gebe all ressourcen aus""" |
"""gebe all ressourcen aus""" |
ret="""<?xml version="1.0" ?> |
ret="""<?xml version="1.0" ?> |
<index>""" |
<index>""" |
for resource in self.ZopeFind(self,obj_metatypes=['ECHO_resource'],search_sub=1): |
for resource in self.ZopeFind(self,obj_metatypes=['ECHO_resource','VLP_resource'],search_sub=1): |
|
|
echo_url=resource[1].absolute_url() |
echo_url=resource[1].absolute_url() |
if hasattr(resource[1],'link'): |
if hasattr(resource[1],'link'): |