version 1.304, 2009/04/14 16:31:27
|
version 1.313, 2012/01/04 11:21:10
|
Line 21 import tempfile
|
Line 21 import tempfile
|
import zipfile |
import zipfile |
import re |
import re |
import os,shutil |
import os,shutil |
|
import traceback |
import OFS.Image |
import OFS.Image |
from types import * |
from types import * |
from OFS.Cache import Cacheable |
from OFS.Cache import Cacheable |
Line 57 import Ft.Xml.XPath
|
Line 58 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 382 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 703 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 891 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 879 class ECHO_collection(CatalogAware, Fold
|
Line 918 class ECHO_collection(CatalogAware, Fold
|
pt.content_type="text/html" |
pt.content_type="text/html" |
return pt() |
return pt() |
|
|
|
def changeMetaLinks(self): |
|
"""change form""" |
|
pt=zptFile(self, 'zpt/changeMetaLinkForm') |
|
pt.content_type="text/html" |
|
return pt() |
|
|
def changeTitles(self): |
def changeTitles(self): |
"""change form""" |
"""change form""" |
pt=zptFile(self, 'zpt/changeTitleForm') |
pt=zptFile(self, 'zpt/changeTitleForm') |
Line 999 class ECHO_collection(CatalogAware, Fold
|
Line 1044 class ECHO_collection(CatalogAware, Fold
|
pass |
pass |
return ret |
return ret |
|
|
def importCollection(self,path=None,RESPONSE=None): |
def changeMetaLinksInCollection(self): |
|
"""change all lables of a collection""" |
|
ret="" |
|
argv=self.REQUEST.form |
|
|
|
resources=self.ZopeFind(self,obj_metatypes=['ECHO_pageTemplate','ECHO_movie','ECHO_resource','ECHO_collection','ECHO_link','ECHO_externalLink']) |
|
for resource in resources: |
|
|
|
try: |
|
ret+=resource[1].getId()+" "+argv[resource[1].getId()]+"</br>" |
|
resource[1].metalink=argv[resource[1].getId()][0:] |
|
except: |
|
pass |
|
return ret |
|
|
|
def importCollection(self,path=None,viewerUrl=None,metaDataUrl=None,replacePathPermanent=None,replacePathExperimental=None,folderListFile=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) & (folderListFile is None): |
pt=zptFile(self, 'zpt/importCollection.zpt') |
pt=zptFile(self, 'zpt/importCollection.zpt') |
return pt() |
return pt() |
|
|
|
|
|
|
|
if (path !=""): |
files=os.listdir(path) |
files=os.listdir(path) |
|
pathToFolder=path; |
|
else: |
|
pathToFolder=""; |
|
files=[]; |
|
for fileLine in folderListFile.readlines(): |
|
for fileLine2 in fileLine.split("\r"): |
|
logging.debug("append:"+fileLine2) |
|
files.append(fileLine2) |
|
|
ret="" |
ret="" |
for fileName in files: |
for fileName in files: |
|
|
if fileName: |
if fileName: |
|
logging.debug("split:"+fileName); |
|
if(pathToFolder==""): # pfad ist leer, da filename aud folderlistfile dann: |
|
splitted=fileName.split("/"); |
|
path="/".join(splitted[0:-1]); |
|
fileName=splitted[-1].rstrip().lstrip(); |
|
|
|
|
|
|
|
if (replacePathExperimental and replacePathExperimental!=''): |
|
path=re.sub(replacePathExperimental,"/mpiwg/online/experimental",path) |
|
|
tempPath=re.sub("/mpiwg/online","",path) |
if (replacePathPermanent and replacePathPermanent!=''): |
link="http://echo.mpiwg-berlin.mpg.de/zogilib_book?fn="+tempPath+"/"+fileName+"/pageimg" |
path=re.sub(replacePathPermanent,"/mpiwg/online/permanent",path) |
|
|
|
link=viewerUrl%(path+"/"+fileName+"/pageimg") |
|
|
|
metalink=metaDataUrl+re.sub("/mpiwg/online/","",path+"/"+fileName+"/index.meta") |
|
|
|
#metalink=metaDataUrl+"/"+path+"/"+fileName+"/index.meta" |
|
|
|
newindexMeta =re.sub("/mpiwg/online/","",path+"/"+fileName) |
|
|
metalink=self.path+"/"+fileName+"/index.meta" |
|
try: |
try: |
|
type=self.metadata.getBibTypeFromIndexMeta(newindexMeta) |
|
|
#link="http://nausikaa2.mpiwg-berlin.mpg.de/cgi-bin/toc/toc.x.cgi?dir="+fileName+"&step=thumb" |
try: |
|
|
newObj=ECHO_resource(fileName,link,metalink,fileName,fileName,fileName,'generated','book','','','','','','') |
#link="http://nausikaa2.mpiwg-berlin.mpg.de/cgi-bin/toc/toc.x.cgi?dir="+fileName+"&step=thumb" |
|
logging.debug("create:"+fileName); |
|
logging.debug("type:"+type); |
|
newObj=ECHO_resource(fileName,link,metalink,fileName,fileName,fileName,'',type,'','','','','','') |
self._setObject(fileName,newObj) |
self._setObject(fileName,newObj) |
|
|
genObj=getattr(self,fileName) |
genObj=getattr(self,fileName) |
#genObj.createIndexFile() |
#genObj.createIndexFile() |
ret+="OK:"+fileName+"<br/>" |
ret+="OK:"+fileName+"<br/>" |
except: |
except: |
print "ERROR" |
exc_type, exc_value, exc_traceback = sys.exc_info(); |
|
#logging.error("%s %s %s"%[sys.exc_info()[0],ssys.exc_info()[1],; |
|
traceback.print_exception(exc_type, exc_value, exc_traceback, |
|
limit=2, file=sys.stdout) |
ret+="ERROR:"+fileName+"<br/>" |
ret+="ERROR:"+fileName+"<br/>" |
|
except: |
|
exc_type, exc_value, exc_traceback = sys.exc_info(); |
|
#logging.error("%s %s %s"%[sys.exc_info()[0],ssys.exc_info()[1],; |
|
traceback.print_exception(exc_type, exc_value, exc_traceback, |
|
limit=2, file=sys.stdout) |
|
ret+="not a file ERROR:"+fileName+"<br/>" |
|
|
return ret |
return ret |
|
|
Line 1077 class ECHO_collection(CatalogAware, Fold
|
Line 1179 class ECHO_collection(CatalogAware, Fold
|
RESPONSE.write("<html><body>") |
RESPONSE.write("<html><body>") |
|
|
for resource in resources: |
for resource in resources: |
|
resource[1].newViewer=newViewer; |
|
|
done,msg=resource[1].changeViewer(newViewer) |
# done,msg=resource[1].changeViewer(newViewer) |
if done: |
# if done: |
if RESPONSE is not None: |
# if RESPONSE is not None: |
RESPONSE.write("<p>OK: %s"%resource[0]) |
# RESPONSE.write("<p>OK: %s"%resource[0]) |
else: |
# else: |
if RESPONSE is not None: |
# if RESPONSE is not None: |
RESPONSE.write("<p><a href='%s'>ERROR: %s (%s)</a>"%(resource[1].absolute_url()+'/ECHO_resource_config_main',resource[0],msg)) |
# RESPONSE.write("<p><a href='%s'>ERROR: %s (%s)</a>"%(resource[1].absolute_url()+'/ECHO_resource_config_main',resource[0],msg)) |
|
|
|
|
|
|
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): |
def setStartpageFolderForm(self): |
"""Form for changing the startpage""" |
"""Form for changing the startpage""" |
Line 1394 class ECHO_collection(CatalogAware, Fold
|
Line 1485 class ECHO_collection(CatalogAware, Fold
|
{'label':'Main Config','action':'ECHO_collection_config'}, |
{'label':'Main Config','action':'ECHO_collection_config'}, |
{'label':'Change Labels','action':'changeLabels'}, |
{'label':'Change Labels','action':'changeLabels'}, |
{'label':'Change Titles','action':'changeTitles'}, |
{'label':'Change Titles','action':'changeTitles'}, |
|
{'label':'Change MetaLinks','action':'changeMetaLinks'}, |
{'label':'Localize','action':'localizeObjects'}, |
{'label':'Localize','action':'localizeObjects'}, |
{'label':'Change Weights','action':'changeWeights'}, |
{'label':'Change Weights','action':'changeWeights'}, |
{'label':'Rerender Labels and Titles','action':'ECHO_rerenderLinksMDWarning'}, |
{'label':'Rerender Labels and Titles','action':'ECHO_rerenderLinksMDWarning'}, |
Line 1401 class ECHO_collection(CatalogAware, Fold
|
Line 1493 class ECHO_collection(CatalogAware, Fold
|
{'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':'Set Startpage','action':'setStartpageFolderForm'}, |
{'label':'Change Viewer Templates and Image Viewer','action':'changeViewerTemplateSetsForm'}, |
{'label':'Change Image Viewer','action':'changeViewerTemplateSetsForm'}, |
{'label':'Reload Metadata','action':'reloadMetaDataFromStorageWarning'}, |
{'label':'Reload Metadata','action':'reloadMetaDataFromStorageWarning'}, |
{'label':'ImportCollection','action':'importCollection'}, |
{'label':'ImportCollection','action':'importCollection'}, |
{'label':'Copy MD for indexing and search','action':'copySearchFields'}, |
{'label':'Copy MD for indexing and search','action':'copySearchFields'}, |
Line 1463 class ECHO_collection(CatalogAware, Fold
|
Line 1555 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 1617 class ECHO_group(ECHO_collection):
|
Line 1716 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 1910 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 1877 class ECHO_root(Folder,Persistent,Implic
|
Line 1977 class ECHO_root(Folder,Persistent,Implic
|
getSubCols = ECHO_helpers.getSubCols |
getSubCols = ECHO_helpers.getSubCols |
|
|
manage_options=Folder.manage_options+( |
manage_options=Folder.manage_options+( |
{'label':'Main Config','action':'ECHO_copyright_configForm'}, |
|
{'label':'Reload Metadata','action':'reloadMetaDataFromStorageWarning'}, |
{'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'}, |
Line 1886 class ECHO_root(Folder,Persistent,Implic
|
Line 1985 class ECHO_root(Folder,Persistent,Implic
|
) |
) |
|
|
|
|
|
|
|
|
def getECHORootURL(self): |
def getECHORootURL(self): |
return self.absolute_url() |
return self.absolute_url() |
|
|
Line 2062 class ECHO_root(Folder,Persistent,Implic
|
Line 2163 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 2172 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 2165 class ECHO_root(Folder,Persistent,Implic
|
Line 2266 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 2242 class ECHO_root(Folder,Persistent,Implic
|
Line 2343 class ECHO_root(Folder,Persistent,Implic
|
retStr+="""<option value="%s">%s\n"""%(contentType[0],contentType[0]) |
retStr+="""<option value="%s">%s\n"""%(contentType[0],contentType[0]) |
except: |
except: |
try: |
try: |
for contentType in self.ZopeFind(self.standardMD,obj_metatypes=["OSAS_MetadataMapping"]): |
for contentType in self.ZopeFind(self.getStandardMD(),obj_metatypes=["OSAS_MetadataMapping"]): |
if selected and (contentType[0]==selected): |
if selected and (contentType[0]==selected): |
retStr+="""<option selected value="%s">%s\n"""%(contentType[0],contentType[0]) |
retStr+="""<option selected value="%s">%s\n"""%(contentType[0],contentType[0]) |
else: |
else: |