version 1.262, 2006/02/14 17:28:52
|
version 1.277, 2006/10/18 15:16:23
|
Line 18 except:
|
Line 18 except:
|
import urlparse |
import urlparse |
import string |
import string |
import tempfile |
import tempfile |
|
import zipfile |
import re |
import re |
import os |
import os,shutil |
import OFS.Image |
import OFS.Image |
from types import * |
from types import * |
from OFS.Cache import Cacheable |
from OFS.Cache import Cacheable |
Line 34 from Globals import DTMLFile
|
Line 35 from Globals import DTMLFile
|
import Globals |
import Globals |
from Products.PageTemplates.PageTemplateFile import PageTemplateFile |
from Products.PageTemplates.PageTemplateFile import PageTemplateFile |
from Products.PageTemplates.PageTemplate import PageTemplate |
from Products.PageTemplates.PageTemplate import PageTemplate |
from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate |
from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate,manage_addPageTemplate |
from Globals import Persistent, package_home |
from Globals import Persistent, package_home |
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 |
|
|
import urllib |
import urllib |
import cgi |
import cgi |
Line 66 import urllib
|
Line 68 import urllib
|
import xml.dom.minidom |
import xml.dom.minidom |
import ECHO_helpers |
import ECHO_helpers |
from ECHO_helpers import * |
from ECHO_helpers import * |
|
|
|
try: |
from ECHO_language import * |
from ECHO_language import * |
|
except: |
|
print "no echo_language" |
|
class ECHO_language: |
|
""" leere Klasse""" |
|
pass |
|
|
from ECHO_movie import * |
from ECHO_movie import * |
import vlp_xmlhelpers #TODO: vlp elemente aus echo herausnehmen |
import vlp_xmlhelpers #TODO: vlp elemente aus echo herausnehmen |
import xmlrpclib |
import xmlrpclib |
|
|
|
|
|
|
|
|
|
def normalizeCt(str): |
|
"""normalizes content_type""" |
|
#str= str.replace(" ","_") |
|
return str.replace("-"," ").lower() |
|
|
def setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight,coordstrs=""): |
def setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight,coordstrs=""): |
|
|
"""Allegemeine Informationen zu einer ECHO Collection""" |
"""Allegemeine Informationen zu einer ECHO Collection""" |
Line 342 class ECHO_fullText(ZopePageTemplate,ECH
|
Line 359 class ECHO_fullText(ZopePageTemplate,ECH
|
def getPage(self,nr='1'): |
def getPage(self,nr='1'): |
"""get page n""" |
"""get page n""" |
#return self().encode('latin-1','ignore') |
#return self().encode('latin-1','ignore') |
dom=xml.dom.minidom.parseString(self().encode('utf-8','ignore')) |
dom=xml.dom.minidom.parseString(self()) |
pages=dom.getElementsByTagName('page') |
pages=dom.getElementsByTagName('page') |
|
|
return pages[int(nr)-1].toxml() |
return pages[int(nr)-1].toxml() |
Line 632 class ECHO_resource(CatalogAware,Folder,
|
Line 649 class ECHO_resource(CatalogAware,Folder,
|
|
|
#print ECHO_helpers.urlopen(self.absolute_url()+'/setAccessRightXML'+'?'+params).read() |
#print ECHO_helpers.urlopen(self.absolute_url()+'/setAccessRightXML'+'?'+params).read() |
|
|
|
tries=0 |
|
for i in range(10): |
|
x=ECHO_helpers.urlopen('http://echo.mpiwg-berlin.mpg.de/echo_nav/storage/downloadExternalXML?index_meta_url=%s&xml_url=%s'%(self.metalink,self.absolute_url()+'/setAccessRightXML'+urllib.quote('?'+params))).read() |
|
if x=="ok": |
|
|
|
break; |
|
|
ECHO_helpers.urlopen('http://echo.mpiwg-berlin.mpg.de/echo_nav/storage/downloadExternalXML?index_meta_url=%s&xml_url=%s'%(self.metalink,self.absolute_url()+'/setAccessRightXML'+urllib.quote('?'+params))).read() |
|
|
|
|
|
if RESPONSE is not None: |
if RESPONSE is not None: |
Line 793 class ECHO_resource(CatalogAware,Folder,
|
Line 815 class ECHO_resource(CatalogAware,Folder,
|
params="startpage=%s"%startpage |
params="startpage=%s"%startpage |
#print 'http://xserve02.mpiwg-berlin.mpg.de:18880/echo_nav/storage/downloadExternalXML?index_meta_url=%s&xml_url=%s'%(self.metalink,self.absolute_url()+'/newMetaXML'+urllib.quote('?'+params)) |
#print 'http://xserve02.mpiwg-berlin.mpg.de:18880/echo_nav/storage/downloadExternalXML?index_meta_url=%s&xml_url=%s'%(self.metalink,self.absolute_url()+'/newMetaXML'+urllib.quote('?'+params)) |
|
|
ECHO_helpers.urlopen('http://xserve02.mpiwg-berlin.mpg.de:18880/echo_nav/storage/downloadExternalXML?index_meta_url=%s&xml_url=%s'%(self.metalink,self.absolute_url()+'/newMetaXML'+urllib.quote('?'+params))).read() |
tries=0 |
|
for i in range(10): |
|
x=ECHO_helpers.urlopen('http://xserve02.mpiwg-berlin.mpg.de:18880/echo_nav/storage/downloadExternalXML?index_meta_url=%s&xml_url=%s'%(self.metalink,self.absolute_url()+'/newMetaXML'+urllib.quote('?'+params))).read() |
|
if x=="ok": |
|
|
|
break; |
|
|
|
|
path=self.metalink |
path=self.metalink |
Line 823 class ECHO_resource(CatalogAware,Folder,
|
Line 850 class ECHO_resource(CatalogAware,Folder,
|
return pt() |
return pt() |
|
|
|
|
|
def setLink(self, link=None): |
|
"""change link field""" |
|
if link is not None: |
|
self.link = link |
|
|
|
|
def getTextToolsField(self,name,default=''): |
def getTextToolsField(self,name,default=''): |
"""Lese Textoolsfelder aus index.meta im path aus""" |
"""Lese Textoolsfelder aus index.meta im path aus""" |
Line 853 class ECHO_resource(CatalogAware,Folder,
|
Line 885 class ECHO_resource(CatalogAware,Folder,
|
params="project=%s&xslt=%s&thumbtemplate=%s&topbar=%s&digiLibTemplate=%s&digiliburlprefix=%s"%(project,xslt,thumbtemplate,topbar,digiLibTemplate,digiliburlprefix) |
params="project=%s&xslt=%s&thumbtemplate=%s&topbar=%s&digiLibTemplate=%s&digiliburlprefix=%s"%(project,xslt,thumbtemplate,topbar,digiLibTemplate,digiliburlprefix) |
|
|
try: |
try: |
ECHO_helpers.urlopen('http://echo.mpiwg-berlin.mpg.de/echo_nav/storage/downloadExternalXML?index_meta_url=%s&xml_url=%s'%(self.metalink,self.absolute_url()+'/newMetaXML'+urllib.quote('?'+params))).read() |
tries=0 |
|
for i in range(10): |
|
x=ECHO_helpers.urlopen('http://echo.mpiwg-berlin.mpg.de/echo_nav/storage/downloadExternalXML?index_meta_url=%s&xml_url=%s'%(self.metalink,self.absolute_url()+'/newMetaXML'+urllib.quote('?'+params))).read() |
|
if x=="ok": |
|
|
|
break; |
|
|
except: |
except: |
zLOG.LOG("ECHO_ressource (changeViewerTemplateSet)", zLOG.ERROR,"%s (%s)"%sys.exc_info()[0:2]) |
zLOG.LOG("ECHO_ressource (changeViewerTemplateSet)", zLOG.ERROR,"%s (%s)"%sys.exc_info()[0:2]) |
zLOG.LOG("ECHO_ressource (changeViewerTemplateSet)", zLOG.ERROR,'http://echo.mpiwg-berlin.mpg.de/echo_nav/storage/downloadExternalXML?index_meta_url=%s&xml_url=%s'%(self.metalink,self.absolute_url()+'/newMetaXML'+urllib.quote('?'+params))) |
zLOG.LOG("ECHO_ressource (changeViewerTemplateSet)", zLOG.ERROR,'http://echo.mpiwg-berlin.mpg.de/echo_nav/storage/downloadExternalXML?index_meta_url=%s&xml_url=%s'%(self.metalink,self.absolute_url()+'/newMetaXML'+urllib.quote('?'+params))) |
Line 865 class ECHO_resource(CatalogAware,Folder,
|
Line 903 class ECHO_resource(CatalogAware,Folder,
|
|
|
path=re.sub('/index.meta','',path) |
path=re.sub('/index.meta','',path) |
|
|
path=re.sub(self.REQUEST['SERVER_URL'],'',path) |
#TODO: direct access to the file system necessary, fix that also xmlrpc to the server where the index file is stored is possible |
path=re.sub('http://'+self.REQUEST['HTTP_HOST'],'',path) |
parsedUrl=urlparse.urlparse(path) |
|
path=parsedUrl[2] |
path=re.sub('http://foxridge.mpiwg-berlin.mpg.de:8080','',path) # falls foxridge als server |
|
path=re.sub('http://foxridge.mpiwg-berlin.mpg.de:8080','',path) # falls foxridge als server |
|
path=re.sub('http://foxridge.mpiwg-berlin.mpg.de','',path) # falls foxridge als server |
|
|
|
path=re.sub('http://foxridge.rz-berlin.mpg.de:8080','',path) # falls foxridge als server |
|
path=re.sub('http://foxridge.rz-berlin.mpg.de','',path) # falls foxridge als server |
|
path=re.sub('http://content.mpiwg-berlin.mpg.de','',path) # falls content als server |
|
path=re.sub('http://echo.mpiwg-berlin.mpg.de','',path) # falls echo |
|
|
|
path=re.sub('http://vision.rz-berlin.mpg.de','',path) # falls vision als server |
|
|
|
|
try: |
return ECHO_helpers.urlopen("http://nausikaa2.rz-berlin.mpg.de:86/cgi-bin/toc/admin/reg.cgi?path=%s"%path).readlines() |
return ECHO_helpers.urlopen("http://nausikaa2.rz-berlin.mpg.de:86/cgi-bin/toc/admin/reg.cgi?path=%s"%path).readlines() |
|
except: |
|
zLOG.LOG("ECHO_Resource (changeViewerTemplateSet)", zLOG.INFO,"%s (%s)"%sys.exc_info()[0:2]) |
|
zLOG.LOG("ECHO_Resource (changeViewerTemplateSet)", zLOG.INFO,"http://nausikaa2.rz-berlin.mpg.de:86/cgi-bin/toc/admin/reg.cgi?path=%s"%path) |
|
|
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
Line 1016 class ECHO_resource(CatalogAware,Folder,
|
Line 1047 class ECHO_resource(CatalogAware,Folder,
|
else: |
else: |
return '' |
return '' |
|
|
|
def getOwnerOriginalsHTML(self): |
|
"""gibt Liste der foerdernden Institutionen aus""" |
|
|
|
if hasattr(self,'ownerOriginal'): |
|
obj=self.ownerOriginal |
|
ret=obj.getOwner() |
|
return ret |
|
else: |
|
return '' |
|
|
|
def getDigiCopyByHTML(self): |
|
"""gibt Liste der foerdernden Institutionen aus""" |
|
|
|
if hasattr(self,'digiCopyBy'): |
|
obj=self.digiCopyBy |
|
ret=obj.getDigiCopyBy() |
|
return ret |
|
else: |
|
return '' |
|
|
def getCredits(self): |
def getCredits(self): |
"""Ausgabe der credits""" |
"""Ausgabe der credits""" |
Line 1056 class ECHO_resource(CatalogAware,Folder,
|
Line 1106 class ECHO_resource(CatalogAware,Folder,
|
|
|
def getContentType(self): |
def getContentType(self): |
try: |
try: |
return self.contentType |
return normalizeCt(self.contentType) |
except: |
except: |
return "" |
return "" |
|
|
Line 1171 class ECHO_resource(CatalogAware,Folder,
|
Line 1221 class ECHO_resource(CatalogAware,Folder,
|
|
|
def changeECHO_resource_metadata_local(self,RESPONSE=None): |
def changeECHO_resource_metadata_local(self,RESPONSE=None): |
"""change metadata""" |
"""change metadata""" |
tags=self.findTagsFromMapping(self.contentType) |
tags=self.findTagsFromMapping(normalizeCt(self.contentType)) |
for field in tags[1]: |
for field in tags[1]: |
self.metaDataHash[self.getFieldTag(tags,field)]=self.REQUEST.form[self.getFieldTag(tags,field)][0:] |
self.metaDataHash[self.getFieldTag(tags,field)]=self.REQUEST.form[self.getFieldTag(tags,field)][0:] |
|
|
Line 1182 class ECHO_resource(CatalogAware,Folder,
|
Line 1232 class ECHO_resource(CatalogAware,Folder,
|
|
|
def changeECHO_resource_metadata(self,RESPONSE=None): |
def changeECHO_resource_metadata(self,RESPONSE=None): |
"""change metadata""" |
"""change metadata""" |
tags=self.findTagsFromMapping(self.contentType) |
tags=self.findTagsFromMapping(normalizeCt(self.contentType)) |
self.OSAS_meta={} |
self.OSAS_meta={} |
for field in tags[1]: |
for field in tags[1]: |
try: |
try: |
Line 1192 class ECHO_resource(CatalogAware,Folder,
|
Line 1242 class ECHO_resource(CatalogAware,Folder,
|
zLOG.LOG("ECHO_collection (changeECHO_resource_metadata)",zLOG.ERROR,"%s (%s)"%sys.exc_info()[0:2]) |
zLOG.LOG("ECHO_collection (changeECHO_resource_metadata)",zLOG.ERROR,"%s (%s)"%sys.exc_info()[0:2]) |
|
|
print self.newMetaXML() |
print self.newMetaXML() |
ECHO_helpers.urlopen('http://xserve02.mpiwg-berlin.mpg.de:18880/echo_nav/storage/downloadExternalXML?index_meta_url=%s&xml_url=%s'%(self.metalink,self.absolute_url()+'/newMetaXML')).read() |
tries=0 |
|
for i in range(10): |
|
x=ECHO_helpers.urlopen('http://xserve02.mpiwg-berlin.mpg.de:18880/echo_nav/storage/downloadExternalXML?index_meta_url=%s&xml_url=%s'%(self.metalink,self.absolute_url()+'/newMetaXML')).read() |
|
if x=="ok": |
|
|
|
break; |
|
|
|
|
|
|
if RESPONSE is not None: |
if RESPONSE is not None: |
Line 1222 class ECHO_resource(CatalogAware,Folder,
|
Line 1278 class ECHO_resource(CatalogAware,Folder,
|
if generic: |
if generic: |
if self.contentType: |
if self.contentType: |
ct=self.contentType.replace(" ","_").lower() |
ct=self.contentType.replace(" ","_").lower() |
|
ct=self.contentType.replace("-","_").lower() |
else: |
else: |
zLOG.LOG("ECHO_collection (getMDValue)", zLOG.INFO, "no_content type for %s"%self.getId()) |
zLOG.LOG("ECHO_collection (getMDValue)", zLOG.INFO, "no_content type for %s"%self.getId()) |
ct="" |
ct="" |
Line 1230 class ECHO_resource(CatalogAware,Folder,
|
Line 1287 class ECHO_resource(CatalogAware,Folder,
|
if not hasattr(self,'_v_mapHash'): #noch keine cachevariable |
if not hasattr(self,'_v_mapHash'): #noch keine cachevariable |
self._v_mapHash={} |
self._v_mapHash={} |
|
|
|
|
|
|
tmp=self._v_mapHash.get(ct,None) |
tmp=self._v_mapHash.get(ct,None) |
if tmp: #teste ob type schon existiert |
if tmp: #teste ob type schon existiert |
fieldName=tmp.get(fieldNameTest,None) |
fieldName=tmp.get(fieldNameTest,None) |
else: |
else: |
self._v_mapHash[ct]={} |
self._v_mapHash[ct]={} |
|
|
|
|
#noch nicht gecached |
#noch nicht gecached |
if not fieldName and hasattr(self.standardMD,ct): |
if not fieldName and hasattr(self.standardMD,ct): |
fieldName=getattr(self.standardMD,ct).generateMappingHash()[fieldNameTest][0] |
fieldName=getattr(self.standardMD,ct).generateMappingHash()[fieldNameTest][0] |
Line 1246 class ECHO_resource(CatalogAware,Folder,
|
Line 1306 class ECHO_resource(CatalogAware,Folder,
|
#FIXME: warum gibt es manchmal kein metadatahas |
#FIXME: warum gibt es manchmal kein metadatahas |
try: |
try: |
|
|
ret =self.metaDataHash.get(fieldName,'!!NOT USED HERE in Type: %s'%self.contentType) |
ret =self.metaDataHash.get(fieldName,'!!NOT USED HERE in Type: %s'%normalizeCt(self.contentType)) |
except: |
except: |
zLOG.LOG("ECHO (line 1069)",zLOG.ERROR,"no md hash for %s"%self.getId()) |
zLOG.LOG("ECHO (line 1069)",zLOG.ERROR,"no md hash for %s"%self.getId()) |
return "" |
return "" |
Line 1271 class ECHO_resource(CatalogAware,Folder,
|
Line 1331 class ECHO_resource(CatalogAware,Folder,
|
|
|
self.copyIndex_meta2echo_resource() |
self.copyIndex_meta2echo_resource() |
try: |
try: |
|
|
|
|
return writeMetadata(self.metalink,self.OSAS_meta,project,startpage,xslt,thumbtemplate,topbar,digiLibTemplate,digiliburlprefix=digiliburlprefix) |
return writeMetadata(self.metalink,self.OSAS_meta,project,startpage,xslt,thumbtemplate,topbar,digiLibTemplate,digiliburlprefix=digiliburlprefix) |
except: |
except: |
|
#print self.metalink,self.metaDataHash,project,startpage,xslt,thumbtemplate,topbar,digiLibTemplate,digiliburlprefix |
|
|
return writeMetadata(self.metalink,self.metaDataHash,project,startpage,xslt,thumbtemplate,topbar,digiLibTemplate,digiliburlprefix=digiliburlprefix) |
return writeMetadata(self.metalink,self.metaDataHash,project,startpage,xslt,thumbtemplate,topbar,digiLibTemplate,digiliburlprefix=digiliburlprefix) |
|
|
def showMetaDataXML(self,project=None,startpage=None,xslt=None,thumbtemplate=None,topbar=None,digiLibTemplate=None): |
def showMetaDataXML(self,project=None,startpage=None,xslt=None,thumbtemplate=None,topbar=None,digiLibTemplate=None): |
Line 1408 class ECHO_resource(CatalogAware,Folder,
|
Line 1472 class ECHO_resource(CatalogAware,Folder,
|
fields=[] |
fields=[] |
fieldlist=self.standardMD.fieldList |
fieldlist=self.standardMD.fieldList |
|
|
tags=self.findTagsFromMapping(self.contentType) |
tags=self.findTagsFromMapping(normalizeCt(self.contentType)) |
self.referencetypes=tags[2] |
self.referencetypes=tags[2] |
for referenceTypeF in self.referencetypes: |
for referenceTypeF in self.referencetypes: |
|
|
if referenceTypeF[1].title.lower() == referenceType.lower(): |
|
|
if normalizeCt(referenceTypeF[1].title) == normalizeCt(referenceType.lower()): |
|
|
try: |
try: |
bibdata[referenceTypeF[1].title]=referenceTypeF[1].fields |
bibdata[referenceTypeF[1].title]=referenceTypeF[1].fields |
Line 1450 class ECHO_resource(CatalogAware,Folder,
|
Line 1515 class ECHO_resource(CatalogAware,Folder,
|
for referenceTypeF in temp: |
for referenceTypeF in temp: |
#print referenceType |
#print referenceType |
|
|
if referenceTypeF[1].title.lower() == referenceType.lower(): |
if normalizeCt(referenceTypeF[1].title) == normalizeCt(referenceType.lower()): |
try: |
try: |
bibdata[referenceTypeF[1].title]=referenceTypeF[1].fields |
bibdata[referenceTypeF[1].title]=referenceTypeF[1].fields |
referenceType=referenceTypeF[1].title |
referenceType=referenceTypeF[1].title |
Line 1477 class ECHO_resource(CatalogAware,Folder,
|
Line 1542 class ECHO_resource(CatalogAware,Folder,
|
|
|
return "ERROR:",error,self.absolute_url() |
return "ERROR:",error,self.absolute_url() |
|
|
self.contentType=metadict['bib_type'][0:] |
self.contentType=normalizeCt(metadict['bib_type'])[0:] |
fields=self.findTagsFromMapping(self.contentType) |
fields=self.findTagsFromMapping(normalizeCt(self.contentType)) |
|
|
#fields=self.findLabelsFromMapping(self.contentType) |
#fields=self.findLabelsFromMapping(normalizeCt(self.contentType)) |
for field in fields[1]: |
for field in fields[1]: |
|
|
if self.isDefinedInThisSet(fields,field): |
if self.isDefinedInThisSet(fields,field): |
Line 1492 class ECHO_resource(CatalogAware,Folder,
|
Line 1557 class ECHO_resource(CatalogAware,Folder,
|
if RESPONSE: |
if RESPONSE: |
return RESPONSE.redirect('manage_main') |
return RESPONSE.redirect('manage_main') |
|
|
return "OK:",self.absolute_url(),self.contentType |
return "OK:",self.absolute_url(),normalizeCt(self.contentType) |
|
|
def ECHO_getResourceMD(self,template="yes",back=None,overwrite="no"): |
def ECHO_getResourceMD(self,template="yes",back=None,overwrite="no"): |
"""Einlesen der Metadaten und Anlegen dieser Metadaten als Informationen zur Resource""" |
"""Einlesen der Metadaten und Anlegen dieser Metadaten als Informationen zur Resource""" |
Line 1505 class ECHO_resource(CatalogAware,Folder,
|
Line 1570 class ECHO_resource(CatalogAware,Folder,
|
return "ERROR:",error |
return "ERROR:",error |
|
|
if (not self.contentType) or (overwrite=="yes"): |
if (not self.contentType) or (overwrite=="yes"): |
self.contentType=metadict['bib_type'].lower() |
self.contentType=normalizeCt(normalizeCt(metadict['bib_type']).lower()) |
|
|
if not (metadict['bib_type'].lower()==self.contentType.lower()): |
if not (normalizeCt(metadict['bib_type']).lower()==normalizeCt(self.contentType).lower()): |
self.REQUEST.SESSION['contentStorage']=metadict['bib_type'] |
self.REQUEST.SESSION['contentStorage']=normalizeCt(metadict['bib_type']) |
self.REQUEST.SESSION['contentZope']=self.contentType |
self.REQUEST.SESSION['contentZope']=normalizeCt(self.contentType) |
|
|
return zptFile(self, 'zpt/ECHO_getResourceMDErrorContentType.zpt')() |
return zptFile(self, 'zpt/ECHO_getResourceMDErrorContentType.zpt')() |
|
|
Line 1590 class ECHO_resource(CatalogAware,Folder,
|
Line 1655 class ECHO_resource(CatalogAware,Folder,
|
|
|
def generate_label(self): |
def generate_label(self): |
"""Erzeugt_standard_Label aus Template""" |
"""Erzeugt_standard_Label aus Template""" |
pt=getattr(self,"label_template_"+self.contentType.lower()) |
pt=getattr(self,"label_template_"+normalizeCt(self.contentType).lower()) |
|
|
self.label=pt()[0:] |
self.label=pt()[0:] |
return pt() |
return pt() |
Line 1599 class ECHO_resource(CatalogAware,Folder,
|
Line 1664 class ECHO_resource(CatalogAware,Folder,
|
|
|
def generate_title(self,RESPONSE=None): |
def generate_title(self,RESPONSE=None): |
"""Erzeugt_standard_Label aus Template""" |
"""Erzeugt_standard_Label aus Template""" |
pt=getattr(self,"label_template_"+self.contentType.lower()) |
pt=getattr(self,"label_template_"+normalizeCt(self.contentType).lower()) |
|
|
self.title=pt()[0:] |
self.title=pt()[0:] |
|
|
Line 1754 class ECHO_link(ECHO_externalLink):
|
Line 1819 class ECHO_link(ECHO_externalLink):
|
# |
# |
# return ret |
# return ret |
# |
# |
|
def getCopyrightsHTML(self): |
|
"""gib (link auf copyright link, mediatyp, institution, copyrightType, label von copyrightType) aus""" |
|
|
|
if hasattr(self,'copyrightModel'): |
|
obj=self.copyrightModel |
|
|
|
else: |
|
return "ERROR" |
|
ret=[] |
|
|
|
for copyright in obj.getCopyrights(): #copyright - media / partner / copyrightID |
|
|
|
|
|
try: |
|
if hasattr(self.copyrightTypes,copyright[2]): |
|
copyrightTypeObj=getattr(self.copyrightTypes,copyright[2]) |
|
link="copyrightTypes/"+copyright[2]+'/copyright.html' |
|
else: |
|
copyrightTypeObj=getattr(obj,copyright[2]) |
|
link="copyrightModel/"+copyright[2]+'/copyright.html' |
|
|
|
label=copyrightTypeObj.label |
|
url=getattr(copyrightTypeObj, 'url', '') |
|
|
|
if url!='': |
|
ret.append((url,copyright[0],copyright[1],copyright[2],label)) |
|
else: |
|
if hasattr(copyrightTypeObj, 'copyright.html'): |
|
ret.append(("""%s?partner=%s"""%(link,copyright[1]),copyright[0],copyright[1],copyright[2],label)) |
|
else: |
|
ret.append(('empty',copyright[0],copyright[1],copyright[2],label)) |
|
except: |
|
"""nothing""" |
|
|
|
return ret |
|
|
|
def getInstitutionsHTML(self): |
|
"""gibt Liste der foerdernden Institutionen aus""" |
|
|
|
if hasattr(self,'support'): |
|
obj=self.support |
|
ret=obj.getSupporter() |
|
return ret |
|
else: |
|
return '' |
|
|
|
def getOwnerOriginalsHTML(self): |
|
"""gibt Liste der foerdernden Institutionen aus""" |
|
|
|
if hasattr(self,'ownerOriginal'): |
|
obj=self.ownerOriginal |
|
ret=obj.getOwner() |
|
return ret |
|
else: |
|
return '' |
|
|
|
def getDigiCopyByHTML(self): |
|
"""gibt Liste der foerdernden Institutionen aus""" |
|
|
|
if hasattr(self,'digiCopyBy'): |
|
obj=self.digiCopyBy |
|
ret=obj.getDigiCopyBy() |
|
return ret |
|
else: |
|
return '' |
|
|
def index_html(self): |
def index_html(self): |
"""standard link""" |
"""standard link""" |
Line 1812 class ECHO_collection(CatalogAware, Fold
|
Line 1941 class ECHO_collection(CatalogAware, Fold
|
|
|
path="/mpiwg/online/permanent/shipbuilding" |
path="/mpiwg/online/permanent/shipbuilding" |
|
|
|
|
|
def exportImportObjects_html(self,RESPONSE): |
|
"""ImportObject""" |
|
pt=zptFile(self, 'zpt/exportImportObjects.zpt') |
|
pt.content_type="text/html" |
|
return pt() |
|
|
|
def importObjects_html(self,RESPONSE): |
|
"""ImportObject""" |
|
pt=zptFile(self, 'zpt/importObjects.zpt') |
|
pt.content_type="text/html" |
|
return pt() |
|
|
|
def importObjects(self,zfile,RESPONSE=None,REQUEST=None): |
|
"""import object from file""" |
|
|
|
zf=zipfile.ZipFile(zfile,"r") |
|
tmpdir=tempfile.mkdtemp() # create tempdir |
|
ret=None |
|
|
|
for name in zf.namelist(): |
|
fn=tempfile.mkstemp()[1] |
|
tf=file(fn,"w") |
|
x=zf.read(name) |
|
tf.write(x) |
|
tf.close() |
|
try: |
|
self._importObjectFromFile(fn,set_owner=1) |
|
except: |
|
if not ret: |
|
ret="" |
|
ret+="Cannot import: %s (Already existing?)<br>"%name |
|
os.remove(fn) |
|
|
|
if ret: |
|
return """<html><body>%s</body></html>"""%ret |
|
if RESPONSE: |
|
RESPONSE.redirect(self.absolute_url()) |
|
|
|
def exportObjects_html(self,RESPONSE): |
|
"""Export objects""" |
|
|
|
pt=zptFile(self, 'zpt/exportObjects.zpt') |
|
pt.content_type="text/html" |
|
return pt() |
|
|
|
def exportObjects(self,ids,RESPONSE=None): |
|
"""export objects with type id""" |
|
if not (type(ids) is ListType): |
|
ids=[ids] |
|
|
|
tmpdir=tempfile.mkdtemp() # create tempdir |
|
objs=self.ZopeFind(self,obj_ids=ids) |
|
tmpfile=tempfile.mkstemp()[1] |
|
|
|
zf=zipfile.ZipFile(tmpfile,"w") |
|
for obj in objs: |
|
|
|
f = os.path.join(tmpdir, '%s.zexp' %obj[0]) |
|
#print E.absolute_url() |
|
|
|
obj[1]._p_jar.exportFile(obj[1]._p_oid, f) |
|
|
|
zf.write(f,obj[0]) |
|
|
|
zf.close() |
|
shutil.rmtree(tmpdir) |
|
if RESPONSE: |
|
RESPONSE.setHeader("Content-Type","application/octet-stream") |
|
len=os.stat(tmpfile)[6] |
|
RESPONSE.setHeader("Content-Length",len) |
|
RESPONSE.setHeader("Content-Disposition","""attachement; filename=%s"""%"export.zip") |
|
fh=file(tmpfile) |
|
for x in fh.read(): |
|
RESPONSE.write(x) |
|
fh.close() |
|
|
def getMDValueSimpleSearchField(self): |
def getMDValueSimpleSearchField(self): |
"""returns value for simple search""" |
"""returns value for simple search""" |
return " ".join([self.title,self.description]) |
return " ".join([self.title,self.description]) |
Line 2194 class ECHO_collection(CatalogAware, Fold
|
Line 2400 class ECHO_collection(CatalogAware, Fold
|
retStr="<option>\n" |
retStr="<option>\n" |
|
|
try: # erste version copyrightTypes exists |
try: # erste version copyrightTypes exists |
for partner in self.credits: |
for partner in self.getPartners(): |
if selected and (partner==selected): |
partnerTitle = partner.title |
retStr+="""<option selected value="%s">%s\n"""%(partner,partner) |
partnerId = partner.__name__ |
|
if selected and (partnerId==selected): |
|
retStr+="""<option selected value="%s">%s\n"""%(partnerId,partnerTitle) |
else: |
else: |
retStr+="""<option value="%s">%s\n"""%(partner,partner) |
retStr+="""<option value="%s">%s\n"""%(partnerId,partnerTitle) |
except: |
except: |
"""nothing""" |
"""nothing""" |
return retStr |
return retStr |
Line 2222 class ECHO_collection(CatalogAware, Fold
|
Line 2430 class ECHO_collection(CatalogAware, Fold
|
for resource in dom.getElementsByTagName('resource'): |
for resource in dom.getElementsByTagName('resource'): |
link=getText(resource.getElementsByTagName('link')[0].childNodes) |
link=getText(resource.getElementsByTagName('link')[0].childNodes) |
label=getText(resource.getElementsByTagName('label')[0].childNodes) |
label=getText(resource.getElementsByTagName('label')[0].childNodes) |
|
pageimglink=getText(resource.getElementsByTagName('pageimglink')[0].childNodes) |
#splitted=link.split("?")[0].split("/") |
#splitted=link.split("?")[0].split("/") |
#id=splitted[len(splitted)-1].encode('ascii') |
#id=splitted[len(splitted)-1].encode('ascii') |
id=re.sub(" ","_",label).encode('ascii') |
id=re.sub(" ","_",label).encode('ascii') |
|
|
ret+="<p>"+label+"</p>" |
ret+="<p>"+label+"</p>" |
manage_addECHO_resource(self,id,label.encode('ascii'),label.encode('ascii'),"","","",link.encode('ascii'),"","") |
manage_addECHO_resource(self,id,label.encode('ascii'),label.encode('ascii'),"","",pageimglink.encode('ascii'),link.encode('ascii'),"","") |
return ret |
return ret |
|
|
security.declarePublic('getImageTag') |
security.declarePublic('getImageTag') |
Line 2383 class ECHO_collection(CatalogAware, Fold
|
Line 2592 class ECHO_collection(CatalogAware, Fold
|
{'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'}, |
|
{'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':'Set Startpage','action':'setStartpageFolderForm'}, |
Line 2856 class ECHO_root(Folder,Persistent,Implic
|
Line 3066 class ECHO_root(Folder,Persistent,Implic
|
meta_type="ECHO_root" |
meta_type="ECHO_root" |
management_page_charset="utf-8" |
management_page_charset="utf-8" |
|
|
|
getSubCols = ECHO_helpers.getSubCols |
|
|
|
manage_options=Folder.manage_options+( |
|
{'label':'Main Config','action':'ECHO_copyright_configForm'}, |
|
{'label':'Reload Metadata','action':'reloadMetaDataFromStorageWarning'}, |
|
{'label':'Change Weights','action':'changeWeights'}, |
|
{'label':'Generate from RDF','action':'generateFromRDFForm'}, |
|
{'label':'update Resource Catalog','action':'updateResourceCatalog'}, |
|
{'label':'Copy MD for indexing and search','action':'copySearchFields'}, |
|
) |
|
|
|
|
|
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""" |
return re.sub(pattern,replace,string) |
return re.sub(pattern,replace,string) |
Line 2894 class ECHO_root(Folder,Persistent,Implic
|
Line 3127 class ECHO_root(Folder,Persistent,Implic
|
if RESPONSE: |
if RESPONSE: |
RESPONSE.write("<p> ok </p></html></body>\n") |
RESPONSE.write("<p> ok </p></html></body>\n") |
|
|
def printer(self,txt): |
|
print txt |
|
print txt[2] |
|
print txt[2].getImageTag() |
|
print "HO" |
|
return txt[2].getImageTag() |
|
|
|
def printer2(self,txt): |
|
print txt |
|
|
|
|
|
def item2(self,txt): |
|
return txt[2] |
|
|
|
def setLanguage(self,lang): |
def setLanguage(self,lang): |
"""Set language cookie""" |
"""Set language cookie""" |
Line 2921 class ECHO_root(Folder,Persistent,Implic
|
Line 3141 class ECHO_root(Folder,Persistent,Implic
|
|
|
self.REQUEST.RESPONSE.setCookie('lang_exhibition',lang,path="/") |
self.REQUEST.RESPONSE.setCookie('lang_exhibition',lang,path="/") |
self.REQUEST.RESPONSE.redirect(self.REQUEST['URL1']) |
self.REQUEST.RESPONSE.redirect(self.REQUEST['URL1']) |
|
|
def getLanguage(self): |
def getLanguage(self): |
"""get language cookie""" |
"""get language cookie""" |
lang= self.REQUEST.cookies.get('lang_exhibition','de') |
lang= self.REQUEST.cookies.get('lang_exhibition','de') |
Line 3110 class ECHO_root(Folder,Persistent,Implic
|
Line 3331 class ECHO_root(Folder,Persistent,Implic
|
pt=zptFile(self, 'zpt/changeWeightForm') |
pt=zptFile(self, 'zpt/changeWeightForm') |
pt.content_type="text/html" |
pt.content_type="text/html" |
return pt() |
return pt() |
getSubCols = ECHO_helpers.getSubCols |
|
|
|
manage_options=Folder.manage_options+( |
|
{'label':'Main Config','action':'ECHO_copyright_configForm'}, |
|
{'label':'Reload Metadata','action':'reloadMetaDataFromStorageWarning'}, |
|
{'label':'Change Weights','action':'changeWeights'}, |
|
{'label':'Generate from RDF','action':'generateFromRDFForm'}, |
|
|
|
) |
|
|
|
|
|
|
|
def reloadMetaDataFromStorageWarning(self,RESPONSE=None): |
def reloadMetaDataFromStorageWarning(self,RESPONSE=None): |
Line 3466 class ECHO_root(Folder,Persistent,Implic
|
Line 3677 class ECHO_root(Folder,Persistent,Implic
|
def getPartners(self): |
def getPartners(self): |
"""Get list of Partners. Presently only from a subfolder partners""" |
"""Get list of Partners. Presently only from a subfolder partners""" |
if hasattr(self,'partners'): |
if hasattr(self,'partners'): |
return [ item[1] for item in self.partners.ZopeFind(self.partners,obj_metatypes=['ECHO_partner'])] |
ret = [ item[1] for item in self.partners.ZopeFind(self.partners,obj_metatypes=['ECHO_partner'])] |
|
def sort_title(one, another) : return cmp(one.title, another.title) |
|
ret.sort(sort_title) |
|
return ret |
else: |
else: |
return [] |
return [] |
|
|
Line 3649 class ECHO_root(Folder,Persistent,Implic
|
Line 3863 class ECHO_root(Folder,Persistent,Implic
|
inst=self.ZopeFind(self.institutions, obj_ids=[id]) |
inst=self.ZopeFind(self.institutions, obj_ids=[id]) |
return inst |
return inst |
|
|
|
def updateResourceCatalog(self,REQUEST,RESPONSE): |
|
"""update ressource catalog""" |
|
catalog=getattr(self,'resourceCatalog',None) |
|
if not catalog: |
|
return """<html><body><h3>No resourceCatalog available</h3></body></html>""" |
|
|
|
else: |
|
class element: |
|
def __init__(self,group,name): |
|
self.group=group |
|
self.name=name |
|
catalog.manage_delObjects('author splitter') |
|
#elements=[element('Stop Words',""" Don't remove stop words' """),element('Word Splitter','ECHO author splitter')] |
|
elements=[element('Word Splitter','ECHO author splitter')] |
|
manage_addLexicon(catalog,id="author splitter",elements=elements) |
|
|
|
return catalog.manage_catalogReindex(REQUEST,RESPONSE,'manage_main') |
|
|
|
|
|
def checkMetaDataLinks(self,correct=None): |
|
"""check all metadatalinks and if correct is set change the servername to content.mpiwg-berlin.mpg.de""" |
|
|
|
self.REQUEST.RESPONSE.write("<html><body>") |
|
for resource in self.ZopeFind(self,obj_metatypes=['ECHO_resource'],search_sub=1): |
|
metalink=resource[1].metalink |
|
|
|
try: |
|
url=urllib.urlopen(metalink) |
|
except: |
|
|
|
self.REQUEST.RESPONSE.write("<p>ERROR (opening %s):"%resource[1].absolute_url() +" -- %s %s <br>"%sys.exc_info()[0:2]) |
|
self.REQUEST.RESPONSE.write("-----------%s"%metalink) |
|
|
|
if correct: |
|
urlparsed=[x for x in urlparse.urlparse(metalink)] |
|
urlparsed[1]="content.mpiwg-berlin.mpg.de" |
|
neu=urlparse.urlunparse(urlparsed) |
|
resource[1].metalink=neu[0:] |
|
self.REQUEST.RESPONSE.write("----------changed to:%s)"%neu) |
|
|
def manage_addECHO_root(self,id,title,RESPONSE=None): |
def manage_addECHO_root(self,id,title,RESPONSE=None): |
"""Add an ECHO_root""" |
"""Add an ECHO_root""" |
Line 3748 class ECHO_linkList(ZopePageTemplate,ECH
|
Line 4001 class ECHO_linkList(ZopePageTemplate,ECH
|
def getcontentType(self): |
def getcontentType(self): |
"""get contentType""" |
"""get contentType""" |
if hasattr(self,'contentType'): |
if hasattr(self,'contentType'): |
return self.contentType |
return normalizeCt(self.contentType) |
else: |
else: |
return 0 |
return 0 |
|
|
Line 3859 def manage_addECHO_support(self, id,inst
|
Line 4112 def manage_addECHO_support(self, id,inst
|
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
|
# ECHO - owner of original |
|
class ECHO_ownerOriginal(Folder,ECHO_basis): |
|
"""besitzer des originals""" |
|
meta_type="ECHO_ownerOriginal" |
|
security=ClassSecurityInfo() |
|
|
|
|
|
def __init__(self,id,institutions=None): |
|
"""init""" |
|
self.id=id |
|
self.title='' |
|
self.institutions=toList(institutions) |
|
|
|
security.declarePublic('getOwner') |
|
def getOwner(self): |
|
"""return institutions""" |
|
if self.institutions: |
|
return self.institutions |
|
else: |
|
return [] |
|
|
|
manage_options = Folder.manage_options+( |
|
{'label':'Main Config','action':'ECHO_ownerOriginal_configForm'}, |
|
) |
|
|
|
def ECHO_ownerOriginal_configForm(self): |
|
"""change form""" |
|
pt=zptFile(self, 'zpt/ChangeECHO_ownerOriginal') |
|
pt.content_type="text/html" |
|
return pt() |
|
|
|
def ECHO_ownerOriginal_config(self,institutions=None,RESPONSE=None): |
|
"""change""" |
|
self.institutions=toList(institutions) |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
|
|
def manage_addECHO_ownerOriginalForm(self): |
|
"""Form for adding""" |
|
pt=zptFile(self, 'zpt/AddECHO_ownerOriginal.zpt') |
|
return pt() |
|
|
|
def manage_addECHO_ownerOriginal(self, id,institutions=None,RESPONSE=None): |
|
"""add the copyright""" |
|
|
|
meta_type="ECHO_ownerOriginal" |
|
|
|
|
|
self._setObject(id, ECHO_ownerOriginal(id,institutions)) |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
# -------------------------------------------------------------------------------- |
|
|
|
# ECHO - digitized copy by |
|
class ECHO_digiCopyBy(Folder,ECHO_basis): |
|
"""besitzer des originals""" |
|
meta_type="ECHO_digiCopyBy" |
|
security=ClassSecurityInfo() |
|
|
|
|
|
def __init__(self,id,institutions=None): |
|
"""init""" |
|
self.id=id |
|
self.title='' |
|
self.institutions=toList(institutions) |
|
|
|
security.declarePublic('getDigiCopyBy') |
|
def getDigiCopyBy(self): |
|
"""return institutions""" |
|
if self.institutions: |
|
return self.institutions |
|
else: |
|
return [] |
|
|
|
manage_options = Folder.manage_options+( |
|
{'label':'Main Config','action':'ECHO_digiCopyBy_configForm'}, |
|
) |
|
|
|
def ECHO_digiCopyBy_configForm(self): |
|
"""change form""" |
|
pt=zptFile(self, 'zpt/ChangeECHO_digiCopyBy') |
|
pt.content_type="text/html" |
|
return pt() |
|
|
|
def ECHO_digiCopyBy_config(self,institutions=None,RESPONSE=None): |
|
"""change""" |
|
self.institutions=toList(institutions) |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
|
|
def manage_addECHO_digiCopyByForm(self): |
|
"""Form for adding""" |
|
pt=zptFile(self, 'zpt/AddECHO_digiCopyBy.zpt') |
|
return pt() |
|
|
|
def manage_addECHO_digiCopyBy(self, id,institutions=None,RESPONSE=None): |
|
"""add the copyright""" |
|
|
|
meta_type="ECHO_digiCopyBy" |
|
|
|
|
|
self._setObject(id, ECHO_digiCopyBy(id,institutions)) |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
# -------------------------------------------------------------------------------- |
|
|
class ECHO_institution(Image,Persistent,ECHO_basis): |
class ECHO_institution(Image,Persistent,ECHO_basis): |
"""ECHO Institution""" |
"""ECHO Institution""" |
Line 3979 def repairCoords(self):
|
Line 4345 def repairCoords(self):
|
col.addMapArea(area) |
col.addMapArea(area) |
msg += "\nDone!" |
msg += "\nDone!" |
return msg |
return msg |
|
|
|
from ECHO_Nav import ECHO_navigation |
|
|
|
class ECHO_main(ECHO_root,ECHO_navigation): |
|
"""echo main object combines ECHO_root and ECHO_navigation""" |
|
|
|
meta_type="ECHO_main" |
|
|
|
def __init__(self,id,title): |
|
"""init""" |
|
self.id=id |
|
self.title=title |
|
self.pathToHierarchy="/"+self.id # hierarchie always starts with the object. |
|
self.displayedMetaTypes=displayTypes |
|
|
|
|
|
manage_options = Folder.manage_options+( |
|
{'label':'Main Config','action':'ECHO_navigationConfigForm'}, |
|
{'label':'Cache','action':'ECHO_cacheManageForm'}, |
|
{'label':'Main Config','action':'ECHO_copyright_configForm'}, |
|
{'label':'Reload Metadata','action':'reloadMetaDataFromStorageWarning'}, |
|
{'label':'Change Weights','action':'changeWeights'}, |
|
{'label':'Generate from RDF','action':'generateFromRDFForm'}, |
|
{'label':'update Resource Catalog','action':'updateResourceCatalog'}, |
|
{'label':'Copy MD for indexing and search','action':'copySearchFields'}, |
|
) |
|
|
|
|
|
def manage_addECHO_mainForm(self): |
|
"""Form for adding""" |
|
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','AddECHO_main.zpt')).__of__(self) |
|
return pt() |
|
|
|
def manage_addECHO_main(self,id,title,RESPONSE=None): |
|
"""Add an ECHO_main""" |
|
self._setObject(id,ECHO_main(id,title)) |
|
|
|
obj=self._getOb(id) |
|
text=file(os.path.join(package_home(globals()),'zpt','main_template')).read() |
|
|
|
manage_addPageTemplate(obj,'main_template',text=text) |
|
|
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |