version 1.304, 2009/04/14 16:31:27
|
version 1.310.2.3, 2012/01/16 18:57:50
|
Line 9 class ECHO_externalLink contains informa
|
Line 9 class ECHO_externalLink contains informa
|
|
|
|
|
""" |
""" |
try: |
|
from reportlab.pdfgen import canvas |
|
from reportlab.lib.pagesizes import A4 |
|
except: |
|
print "PDF generation will not work" |
|
|
|
import urlparse |
import urlparse |
import string |
import string |
Line 49 import urllib2
|
Line 45 import urllib2
|
import cgi |
import cgi |
import smtplib |
import smtplib |
import time |
import time |
from Ft.Xml.Domlette import NonvalidatingReader |
#from Ft.Xml.Domlette import NonvalidatingReader |
from Ft.Xml.Domlette import PrettyPrint, Print |
#from Ft.Xml.Domlette import PrettyPrint, Print |
from Ft.Xml import EMPTY_NAMESPACE |
#from Ft.Xml import EMPTY_NAMESPACE |
|
# |
import Ft.Xml.XPath |
#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 380 class ECHO_fullText(ZopePageTemplate,ECH
|
Line 377 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 701 class ECHO_collection(CatalogAware, Fold
|
Line 698 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 856 class ECHO_collection(CatalogAware, Fold
|
Line 886 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: |
try: |
ret+=content[1].getRDF()+"\n" |
ret+=content[1].getRDF()+"\n" |
except: |
except: |
logging.error("getRDF: "+repr(content[1].getRDF())) |
logging.error("getrdf: "+repr(content[1].getRDF())) |
|
try: |
ret+=self.unicodify(content[1].getRDF())+"\n" |
ret+=self.unicodify(content[1].getRDF())+"\n" |
ret+="""<RDF:Seq RDF:about="%s">\n"""%urn |
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 999 class ECHO_collection(CatalogAware, Fold
|
Line 1033 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 1012 class ECHO_collection(CatalogAware, Fold
|
Line 1046 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) |
|
|
|
if (replacePathPermanent and replacePathPermanent!=''): |
|
path=re.sub(replacePathPermanent,"/mpiwg/online/permanent",path) |
|
|
|
link=viewerUrl%(path+"/"+fileName+"/pageimg") |
|
|
metalink=self.path+"/"+fileName+"/index.meta" |
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 1091 class ECHO_collection(CatalogAware, Fold
|
Line 1130 class ECHO_collection(CatalogAware, Fold
|
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.write("<p>Done</p></body></html>") |
RESPONSE.write("<p>Done</p></body></html>") |
|
|
def changeViewerTemplateSets(self,project,xslt,thumbtemplate,topbar,digiLibTemplate,digiliburlprefix,RESPONSE=None): |
|
"""change the templates""" |
|
|
|
resources=self.ZopeFind(self,obj_metatypes=['ECHO_resource'],search_sub=1) |
|
|
|
for resource in resources: |
|
|
|
resource[1].changeViewerTemplateSet(project,xslt,thumbtemplate,topbar,digiLibTemplate,digiliburlprefix) |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
|
|
def setStartpageFolderForm(self): |
|
"""Form for changing the startpage""" |
|
|
|
|
|
pt=zptFile(self, 'zpt/ChangeECHO_resourceStartPageFolder.zpt') |
|
pt.content_type="text/html" |
|
return pt() |
|
|
|
def setStartpageFolder(self,startpage=None,RESPONSE=None): |
|
"""change the templates""" |
|
|
|
resources=self.ZopeFind(self,obj_metatypes=['ECHO_resource'],search_sub=1) |
|
|
|
for resource in resources: |
|
|
|
resource[1].setStartPage(startpage) |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
def copyTitleToInfoXMLFolder(self,RESPONSE=None): |
def copyTitleToInfoXMLFolder(self,RESPONSE=None): |
"""copy title into the title field of info.xml |
"""copy title into the title field of info.xml |
Line 1157 class ECHO_collection(CatalogAware, Fold
|
Line 1165 class ECHO_collection(CatalogAware, Fold
|
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
def reloadMetaDataFromStorageWarning(self,RESPONSE=None): |
|
"""warning""" |
|
pt=zptFile(self, 'zpt/reloadMetaDataFromStorageWarning.zpt') |
|
pt.content_type="text/html" |
|
return pt() |
|
|
|
def reloadMetaDataFromStorage(self,RESPONSE=None): |
|
"""copy metadata from the storage to ECHO""" |
|
|
|
return reloadMetaDataFromStorage(self,RESPONSE) |
|
|
|
|
|
def getPartnerCopyright(self,name,sonst="generic"): |
def getPartnerCopyright(self,name,sonst="generic"): |
Line 1400 class ECHO_collection(CatalogAware, Fold
|
Line 1398 class ECHO_collection(CatalogAware, Fold
|
{'label':'Export/Import Objects','action':'exportImportObjects_html'}, |
{'label':'Export/Import Objects','action':'exportImportObjects_html'}, |
{'label':'Graphic Coords','action':'ECHO_graphicEntry'}, |
{'label':'Graphic Coords','action':'ECHO_graphicEntry'}, |
{'label':'create resources from XML','action':'createRessourcesFromXMLForm'}, |
{'label':'create resources from XML','action':'createRessourcesFromXMLForm'}, |
{'label':'Set Startpage','action':'setStartpageFolderForm'}, |
|
{'label':'Change Viewer Templates and Image Viewer','action':'changeViewerTemplateSetsForm'}, |
{'label':'Change Viewer Templates and Image Viewer','action':'changeViewerTemplateSetsForm'}, |
{'label':'Reload Metadata','action':'reloadMetaDataFromStorageWarning'}, |
|
{'label':'ImportCollection','action':'importCollection'}, |
{'label':'ImportCollection','action':'importCollection'}, |
{'label':'Copy MD for indexing and search','action':'copySearchFields'}, |
|
{'label':'Change access rights', 'action':'changeAccessRightsCollectionForm'}, |
{'label':'Change access rights', 'action':'changeAccessRightsCollectionForm'}, |
) |
) |
|
|
Line 1463 class ECHO_collection(CatalogAware, Fold
|
Line 1458 class ECHO_collection(CatalogAware, Fold
|
|
|
def showOverview(self): |
def showOverview(self): |
"""overview""" |
"""overview""" |
if 'ECHO_overview.html' in self.__dict__.keys(): |
# use ECHO_overview.html template in this instance |
return getattr(self,'ECHO_overview.html')() |
if 'ECHO_overview.html' in self: |
|
return self['ECHO_overview.html']() |
|
|
|
# use ECHO_overview_main template in path |
|
if hasattr(self, 'ECHO_overview_main'): |
|
return getattr(self, 'ECHO_overview_main')() |
|
|
|
# use template from Product |
pt=zptFile(self, 'zpt/ECHO_content_overview.zpt') |
pt=zptFile(self, 'zpt/ECHO_content_overview.zpt') |
return pt() |
return pt() |
|
|
Line 1473 class ECHO_collection(CatalogAware, Fold
|
Line 1475 class ECHO_collection(CatalogAware, Fold
|
def index_html(self): |
def index_html(self): |
"""standard page""" |
"""standard page""" |
if self.ZCacheable_isCachingEnabled(): |
if self.ZCacheable_isCachingEnabled(): |
|
|
result = self.ZCacheable_get() |
result = self.ZCacheable_get() |
if result is not None: |
if result is not None: |
# Got a cached value. |
# Got a cached value. |
return result |
return result |
|
|
if 'index.html' in self.__dict__.keys(): |
# old Zope 2.9 method |
ret=getattr(self,'index.html')() |
#if 'index.html' in self.__dict__.keys(): |
|
# ret=getattr(self,'index.html')() |
|
|
|
# use Zope 2.12 IContainer for child access |
|
if 'index.html' in self: |
|
# use index.html template if it exists |
|
ret = self['index.html']() |
|
|
elif 'overview' in self.__dict__.keys(): |
elif 'overview' in self: |
|
# use red-rectangle template when there's an 'overview' |
ret=self.showOverview() |
ret=self.showOverview() |
|
|
|
# use getattr for acquisition |
elif hasattr(self,'collection_index_template'): |
elif hasattr(self,'collection_index_template'): |
|
# use 'collection_index_template' in acquisition path |
ret=self.collection_index_template() |
ret=self.collection_index_template() |
elif hasattr(self,'main_index_template'): |
|
|
|
|
elif hasattr(self,'main_index_template'): |
|
# use 'main_index_template' in acquisition path |
ret=self.main_index_template.__of__(self)(self.main_template) |
ret=self.main_index_template.__of__(self)(self.main_template) |
|
|
else: |
else: |
|
# use template from Product |
pt=zptFile(self, 'zpt/ECHO_main_index_template_standard.zpt') |
pt=zptFile(self, 'zpt/ECHO_main_index_template_standard.zpt') |
pt.content_type="text/html" |
pt.content_type="text/html" |
ret=pt.render() |
ret=pt.render() |
Line 1617 class ECHO_group(ECHO_collection):
|
Line 1631 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 1811 class ECHO_userFolder(UserFolder):
|
Line 1825 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 1878 class ECHO_root(Folder,Persistent,Implic
|
Line 1893 class ECHO_root(Folder,Persistent,Implic
|
|
|
manage_options=Folder.manage_options+( |
manage_options=Folder.manage_options+( |
{'label':'Main Config','action':'ECHO_copyright_configForm'}, |
{'label':'Main Config','action':'ECHO_copyright_configForm'}, |
{'label':'Reload Metadata','action':'reloadMetaDataFromStorageWarning'}, |
|
{'label':'Change Weights','action':'changeWeights'}, |
{'label':'Change Weights','action':'changeWeights'}, |
{'label':'Generate from RDF','action':'generateFromRDFForm'}, |
{'label':'Generate from RDF','action':'generateFromRDFForm'}, |
{'label':'update Resource Catalog','action':'updateResourceCatalog'}, |
{'label':'update Resource Catalog','action':'updateResourceCatalog'}, |
{'label':'Copy MD for indexing and search','action':'copySearchFields'}, |
|
) |
) |
|
|
|
|
|
|
|
|
def getECHORootURL(self): |
def getECHORootURL(self): |
return self.absolute_url() |
return self.absolute_url() |
|
|
def getECHORoot(self): |
def getECHORoot(self): |
return self |
return self |
|
|
def copySearchFields(self,RESPONSE=None): |
|
"""copys < metadatafields to the object""" |
|
resources=self.ZopeFind(self,obj_metatypes=['ECHO_resource'],search_sub=1) |
|
|
|
for resource in resources: |
|
|
|
resource[1].copySearchFields() |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
def mod_re_sub(self,pattern,replace,string): |
def mod_re_sub(self,pattern,replace,string): |
"""re.sub aus mod re zur Verfuegung stellen""" |
"""re.sub aus mod re zur Verfuegung stellen""" |
Line 2062 class ECHO_root(Folder,Persistent,Implic
|
Line 2068 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 2071 class ECHO_root(Folder,Persistent,Implic
|
Line 2077 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 2147 class ECHO_root(Folder,Persistent,Implic
|
Line 2153 class ECHO_root(Folder,Persistent,Implic
|
return pt() |
return pt() |
|
|
|
|
def reloadMetaDataFromStorageWarning(self,RESPONSE=None): |
|
"""warning""" |
|
pt=zptFile(self, 'zpt/reloadMetaDataFromStorageWarning.zpt') |
|
pt.content_type="text/html" |
|
return pt() |
|
|
|
def reloadMetaDataFromStorage(self,RESPONSE=None): |
|
"""reload MD from Storage""" |
|
|
|
return reloadMetaDataFromStorage(self,RESPONSE) |
|
|
|
def getRDF(self,urn=None): |
def getRDF(self,urn=None): |
"""rdf of the collection""" |
"""rdf of the collection""" |
|
|
Line 2165 class ECHO_root(Folder,Persistent,Implic
|
Line 2160 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 3206 class ECHO_main(ECHO_root,ECHO_navigatio
|
Line 3201 class ECHO_main(ECHO_root,ECHO_navigatio
|
{'label':'Main Config','action':'ECHO_navigationConfigForm'}, |
{'label':'Main Config','action':'ECHO_navigationConfigForm'}, |
{'label':'Cache','action':'ECHO_cacheManageForm'}, |
{'label':'Cache','action':'ECHO_cacheManageForm'}, |
{'label':'Main Config','action':'ECHO_copyright_configForm'}, |
{'label':'Main Config','action':'ECHO_copyright_configForm'}, |
{'label':'Reload Metadata','action':'reloadMetaDataFromStorageWarning'}, |
|
{'label':'Change Weights','action':'changeWeights'}, |
{'label':'Change Weights','action':'changeWeights'}, |
{'label':'Generate from RDF','action':'generateFromRDFForm'}, |
{'label':'Generate from RDF','action':'generateFromRDFForm'}, |
{'label':'update Resource Catalog','action':'updateResourceCatalog'}, |
{'label':'update Resource Catalog','action':'updateResourceCatalog'}, |