version 1.310.2.1, 2011/10/13 07:48:27
|
version 1.312, 2012/01/03 13:02:31
|
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 17 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 45 import urllib2
|
Line 50 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 |
Line 1033 class ECHO_collection(CatalogAware, Fold
|
Line 1038 class ECHO_collection(CatalogAware, Fold
|
pass |
pass |
return ret |
return ret |
|
|
def importCollection(self,path=None,viewerUrl=None,metaDataUrl=None,replacePathPermanent=None,replacePathExperimental=None,RESPONSE=None): |
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!=''): |
if (replacePathExperimental and replacePathExperimental!=''): |
path=re.sub(replacePathExperimental,"/mpiwg/online/experimental",path) |
path=re.sub(replacePathExperimental,"/mpiwg/online/experimental",path) |
Line 1054 class ECHO_collection(CatalogAware, Fold
|
Line 1078 class ECHO_collection(CatalogAware, Fold
|
|
|
link=viewerUrl%(path+"/"+fileName+"/pageimg") |
link=viewerUrl%(path+"/"+fileName+"/pageimg") |
|
|
metalink=metaDataUrl+"/"+path+"/"+fileName+"/index.meta" |
metalink=metaDataUrl+re.sub("/mpiwg/online/","",path+"/"+fileName+"/index.meta") |
|
|
|
#metalink=metaDataUrl+"/"+path+"/"+fileName+"/index.meta" |
|
|
|
newindexMeta =re.sub("/mpiwg/online/","",path+"/"+fileName) |
|
|
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,'','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 1143 class ECHO_collection(CatalogAware, Fold
|
Line 1185 class ECHO_collection(CatalogAware, Fold
|
RESPONSE.redirect('manage_main') |
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 1178 class ECHO_collection(CatalogAware, Fold
|
Line 1238 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 1411 class ECHO_collection(CatalogAware, Fold
|
Line 1481 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 1471 class ECHO_collection(CatalogAware, Fold
|
Line 1544 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 1886 class ECHO_root(Folder,Persistent,Implic
|
Line 1966 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':'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'}, |
) |
) |
|
|
|
|
Line 1901 class ECHO_root(Folder,Persistent,Implic
|
Line 1982 class ECHO_root(Folder,Persistent,Implic
|
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 2147 class ECHO_root(Folder,Persistent,Implic
|
Line 2237 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 2231 class ECHO_root(Folder,Persistent,Implic
|
Line 2332 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: |
Line 3195 class ECHO_main(ECHO_root,ECHO_navigatio
|
Line 3296 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'}, |