version 1.270, 2006/07/03 17:28:28
|
version 1.297, 2008/11/19 14:22:42
|
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 41 from Products.ZCatalog.CatalogPathAwaren
|
Line 42 from Products.ZCatalog.CatalogPathAwaren
|
from Products.ZCTextIndex.ZCTextIndex import manage_addLexicon |
from Products.ZCTextIndex.ZCTextIndex import manage_addLexicon |
|
|
import urllib |
import urllib |
|
import urllib2 |
import cgi |
import cgi |
import smtplib |
import smtplib |
import time |
import time |
Line 50 from Ft.Xml import EMPTY_NAMESPACE
|
Line 52 from Ft.Xml import EMPTY_NAMESPACE
|
|
|
import Ft.Xml.XPath |
import Ft.Xml.XPath |
import cStringIO |
import cStringIO |
import zLOG |
|
import sys |
import sys |
|
|
try: |
try: |
Line 67 import urllib
|
Line 69 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 |
|
|
|
import logging |
|
|
|
#ersetzt logging.info |
|
def logger(txt,method,txt2): |
|
"""logging""" |
|
logging.info(txt+ txt2) |
|
|
|
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=""): |
|
|
Line 178 class ECHO_locale(ZopePageTemplate):
|
Line 199 class ECHO_locale(ZopePageTemplate):
|
self.lang=lang |
self.lang=lang |
self.title=title |
self.title=title |
self.label=label |
self.label=label |
if text: |
# default content |
|
if not text: |
|
text = open(self._default_content_fn).read() |
|
content_type = 'text/html' |
self.pt_edit(text, content_type) |
self.pt_edit(text, content_type) |
self.id=id |
self.id=id |
|
|
Line 197 class ECHO_locale(ZopePageTemplate):
|
Line 221 class ECHO_locale(ZopePageTemplate):
|
self.title=title |
self.title=title |
self.label=label |
self.label=label |
if not text is None: |
if not text is None: |
|
if content_type is None: |
|
content_type = self.content_type |
self.pt_edit(text, content_type) |
self.pt_edit(text, content_type) |
|
|
if RESPONSE is not None: |
if RESPONSE is not None: |
Line 286 class ECHO_layoutTemplate(ZopePageTempla
|
Line 312 class ECHO_layoutTemplate(ZopePageTempla
|
if text is None: |
if text is None: |
self._default_content_fn = os.path.join(package_home(globals()),'zpt','ECHO_%s_template_standard.zpt'%EchoType) |
self._default_content_fn = os.path.join(package_home(globals()),'zpt','ECHO_%s_template_standard.zpt'%EchoType) |
text = open(self._default_content_fn).read() |
text = open(self._default_content_fn).read() |
|
if content_type is None: |
|
content_type = self.content_type |
self.pt_edit(text, content_type) |
self.pt_edit(text, content_type) |
|
|
|
|
Line 343 class ECHO_fullText(ZopePageTemplate,ECH
|
Line 371 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') |
|
try: |
dom=xml.dom.minidom.parseString(self()) |
dom=xml.dom.minidom.parseString(self()) |
|
except: |
|
dom=xml.dom.minidom.parseString(self().encode('latin-1')) |
pages=dom.getElementsByTagName('page') |
pages=dom.getElementsByTagName('page') |
|
|
return pages[int(nr)-1].toxml() |
return pages[int(nr)-1].toxml() |
Line 398 class ECHO_resource(CatalogAware,Folder,
|
Line 429 class ECHO_resource(CatalogAware,Folder,
|
|
|
getSubCols = ECHO_helpers.getSubCols |
getSubCols = ECHO_helpers.getSubCols |
|
|
|
def index_meta(self,RESPONSE=None): |
|
""" gibt das im metalink gespeicher xml-file zurueck""" |
|
url = self.metalink |
|
txt="" |
|
logging.debug("ml:%s"%url) |
|
try: |
|
page = urllib.urlopen(url); |
|
if RESPONSE: |
|
RESPONSE.setHeader("Content-Type","text/xml") |
|
|
|
txt = page.read(); |
|
except: |
|
logging.error("Cannot read metadata of: %s"%self.getId()) |
|
|
|
return txt |
|
|
def reindex(self): |
def reindex(self): |
"""generate fields for indexing and reindex""" |
"""generate fields for indexing and reindex""" |
|
|
Line 600 class ECHO_resource(CatalogAware,Folder,
|
Line 647 class ECHO_resource(CatalogAware,Folder,
|
try: |
try: |
urllib.urlopen(url) |
urllib.urlopen(url) |
except: |
except: |
zLOG.LOG("ECHO_Resource (getAccessRightMD)", zLOG.INFO,"%s (%s)"%sys.exc_info()[0:2]) |
logger("ECHO_Resource (getAccessRightMD)", logging.INFO,"%s (%s)"%sys.exc_info()[0:2]) |
|
|
return None,getattr(self,'accessRight','') |
return None,getattr(self,'accessRight','') |
|
|
Line 608 class ECHO_resource(CatalogAware,Folder,
|
Line 655 class ECHO_resource(CatalogAware,Folder,
|
try: |
try: |
dom = NonvalidatingReader.parseUri(url) |
dom = NonvalidatingReader.parseUri(url) |
except: |
except: |
zLOG.LOG("ECHO_Resource (getAccessRightMD)", zLOG.INFO,"%s (%s)"%sys.exc_info()[0:2]) |
logger("ECHO_Resource (getAccessRightMD)", logging.INFO,"%s (%s)"%sys.exc_info()[0:2]) |
return (None,"Cannot parse: "+url+"<br>"+"%s (%s)"%sys.exc_info()[0:2]) |
return (None,"Cannot parse: "+url+"<br>"+"%s (%s)"%sys.exc_info()[0:2]) |
|
|
|
|
Line 633 class ECHO_resource(CatalogAware,Folder,
|
Line 680 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 739 class ECHO_resource(CatalogAware,Folder,
|
Line 791 class ECHO_resource(CatalogAware,Folder,
|
|
|
|
|
if (not resourcepath) or (not digiliburlprefix) or (not images): |
if (not resourcepath) or (not digiliburlprefix) or (not images): |
zLOG.LOG("ECHO (createImageUrl)",zLOG.ERROR,"Cannot create ImageUrl for %s"%self.absolute_url()) |
logger("ECHO (createImageUrl)",logging.ERROR,"Cannot create ImageUrl for %s"%self.absolute_url()) |
return None |
return None |
resourcepath=resourcepath.replace('/mpiwg/online','') |
resourcepath=resourcepath.replace('/mpiwg/online','') |
if not digiliburlprefix: digiliburlprefix="http://echo.mpiwg-berlin.mpg.de/zogilib?" |
if not digiliburlprefix: digiliburlprefix="http://echo.mpiwg-berlin.mpg.de/zogilib?" |
Line 794 class ECHO_resource(CatalogAware,Folder,
|
Line 846 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 824 class ECHO_resource(CatalogAware,Folder,
|
Line 881 class ECHO_resource(CatalogAware,Folder,
|
return pt() |
return pt() |
|
|
|
|
def setMetaLink(self, link=None): |
def setLink(self, link=None): |
"""change metalink field""" |
"""change link field""" |
if link is not None: |
if link is not None: |
self.metalink = link |
self.link = link |
|
|
|
|
def getTextToolsField(self,name,default=''): |
def getTextToolsField(self,name,default=''): |
Line 859 class ECHO_resource(CatalogAware,Folder,
|
Line 916 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]) |
logger("ECHO_ressource (changeViewerTemplateSet)", logging.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))) |
logger("ECHO_ressource (changeViewerTemplateSet)", logging.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))) |
#print self.absolute_url()+'/newMetaXML'+urllib.quote'?'+params) |
#print self.absolute_url()+'/newMetaXML'+urllib.quote'?'+params) |
# hack Pfad auf die Dokumente |
# hack Pfad auf die Dokumente |
path=self.metalink |
path=self.metalink |
Line 878 class ECHO_resource(CatalogAware,Folder,
|
Line 941 class ECHO_resource(CatalogAware,Folder,
|
try: |
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: |
except: |
zLOG.LOG("ECHO_Resource (changeViewerTemplateSet)", zLOG.INFO,"%s (%s)"%sys.exc_info()[0:2]) |
logger("ECHO_Resource (changeViewerTemplateSet)", logging.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) |
logger("ECHO_Resource (changeViewerTemplateSet)", logging.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 901 class ECHO_resource(CatalogAware,Folder,
|
Line 964 class ECHO_resource(CatalogAware,Folder,
|
"""getFullTextXML; gives the FullText as an XML Document, and <error></error> if somthing goes wrong.""" |
"""getFullTextXML; gives the FullText as an XML Document, and <error></error> if somthing goes wrong.""" |
|
|
try: |
try: |
#zLOG.LOG("ECHO Fulltext",zLOG.INFO,"open %s"%self.metalink) |
#logger("ECHO Fulltext",logging.INFO,"open %s"%self.metalink) |
fh=ECHO_helpers.urlopen(self.metalink) |
fh=ECHO_helpers.urlopen(self.metalink) |
#zLOG.LOG("ECHO Fulltext",zLOG.INFO,"opened %s"%self.metalink) |
#logger("ECHO Fulltext",logging.INFO,"opened %s"%self.metalink) |
dom=xml.dom.minidom.parse(fh) |
dom=xml.dom.minidom.parse(fh) |
texttools=dom.getElementsByTagName('texttool') |
texttools=dom.getElementsByTagName('texttool') |
text=texttools[0].getElementsByTagName('text') |
text=texttools[0].getElementsByTagName('text') |
texturl=getText(text[0].childNodes) |
texturl=getText(text[0].childNodes) |
|
|
#zLOG.LOG("ECHO Fulltext",zLOG.INFO,"found %s"%texturl) |
#logger("ECHO Fulltext",logging.INFO,"found %s"%texturl) |
fh.close() |
fh.close() |
#zLOG.LOG("ECHO Fulltext",zLOG.INFO,"closed fh") |
#logger("ECHO Fulltext",logging.INFO,"closed fh") |
#keine url |
#keine url |
if not (texturl.split(":")[0] in ['http','ftp','file']): |
if not (texturl.split(":")[0] in ['http','ftp','file']): |
if not noredirect: |
if not noredirect: |
Line 921 class ECHO_resource(CatalogAware,Folder,
|
Line 984 class ECHO_resource(CatalogAware,Folder,
|
|
|
if not noredirect: |
if not noredirect: |
self.REQUEST.RESPONSE.setHeader('Content-Type','text/xml') |
self.REQUEST.RESPONSE.setHeader('Content-Type','text/xml') |
zLOG.LOG("ECHO Fulltext",zLOG.INFO,"redirect to:%s"%texturl) |
logger("ECHO Fulltext",logging.INFO,"redirect to:%s"%texturl) |
self.REQUEST.RESPONSE.redirect(texturl) |
self.REQUEST.RESPONSE.redirect(texturl) |
else: |
else: |
return texturl |
return texturl |
Line 1015 class ECHO_resource(CatalogAware,Folder,
|
Line 1078 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 1055 class ECHO_resource(CatalogAware,Folder,
|
Line 1137 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 1113 class ECHO_resource(CatalogAware,Folder,
|
Line 1195 class ECHO_resource(CatalogAware,Folder,
|
|
|
|
|
|
|
|
def changeViewer(self,newViewer): |
|
"""set newViewer to the url of the new viewer |
|
only if metalink is set, otherwise it gives false |
|
""" |
|
|
|
texterUrl="http://nausikaa2.mpiwg-berlin.mpg.de/digitallibrary/servlet/Texter?fn=/" |
|
|
|
vl,msg=self.checkValidityOfMetaLink() |
|
|
def changeECHO_resource_main(self,metalink,link,title,label,description,contentType,renderingType,weight,resourceID,RESPONSE=None): |
if not vl: #ungueltiger link, versuche neuen |
|
newStr=re.match(".*/mpiwg/online/(.*)",self.metalink) # suche pfad hinter /mpiwg/online |
|
oldLink=self.metalink |
|
|
|
if newStr: |
|
self.metalink=texterUrl+newStr.group(1) |
|
vl,msg=self.checkValidityOfMetaLink() |
|
else: |
|
logging.error("change Viewer XX(mew Metadatafile) %s"%self.metalink) |
|
vl=False |
|
|
|
if not vl: # geht immer noch nicht, dann setzte wieder zurueck |
|
self.metalink=oldLink |
|
|
|
logging.info("change Viewer (mew Metadatafile) %s"%self.metalink) |
|
|
|
if vl: |
|
self.newViewer=newViewer |
|
return vl,msg |
|
else: |
|
return vl,msg |
|
|
|
def checkValidityOfMetaLink(self): |
|
"""checks if the metalink is valid xml""" |
|
|
|
ml=self.metalink |
|
|
|
try: |
|
txt=urllib.urlopen(ml) |
|
|
|
except: |
|
return False,"Cannot open: %s)"%ml |
|
|
|
txt.close() |
|
try: |
|
dom = NonvalidatingReader.parseUri(ml) |
|
except: |
|
return False, "Connot parse: %s)"%ml |
|
|
|
if len(dom.xpath("//texttool"))==0: |
|
return False, "No texttools: %s)"%ml |
|
|
|
return True,"" |
|
|
|
def changeECHO_resource_main(self,metalink,link,title,label,description,contentType,renderingType,weight,resourceID,newViewer='',RESPONSE=None): |
"""Aenderung der Properties""" |
"""Aenderung der Properties""" |
self.resourceID=resourceID |
self.resourceID=resourceID |
self.title=title |
self.title=title |
Line 1128 class ECHO_resource(CatalogAware,Folder,
|
Line 1262 class ECHO_resource(CatalogAware,Folder,
|
self.link=link |
self.link=link |
self.metalink=metalink |
self.metalink=metalink |
|
|
|
self.newViewer=newViewer |
|
|
|
|
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
Line 1170 class ECHO_resource(CatalogAware,Folder,
|
Line 1307 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 1181 class ECHO_resource(CatalogAware,Folder,
|
Line 1318 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: |
self.metaDataHash[self.getFieldTag(tags,field)]=self.REQUEST.form[self.getFieldTag(tags,field)] |
self.metaDataHash[self.getFieldTag(tags,field)]=self.REQUEST.form[self.getFieldTag(tags,field)] |
self.OSAS_meta[self.getFieldTag(tags,field)]=self.REQUEST.form['OSAS_%s'%self.getFieldTag(tags,field)] |
self.OSAS_meta[self.getFieldTag(tags,field)]=self.REQUEST.form['OSAS_%s'%self.getFieldTag(tags,field)] |
except: |
except: |
zLOG.LOG("ECHO_collection (changeECHO_resource_metadata)",zLOG.ERROR,"%s (%s)"%sys.exc_info()[0:2]) |
logger("ECHO_collection (changeECHO_resource_metadata)",logging.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 1208 class ECHO_resource(CatalogAware,Folder,
|
Line 1351 class ECHO_resource(CatalogAware,Folder,
|
self.getMDValue('year',generic="yes"),self.getTitle()]) |
self.getMDValue('year',generic="yes"),self.getTitle()]) |
except: |
except: |
|
|
#zLOG.LOG(" ECHO_collection(getMDSimpleSearchField)",zLOG.INFO," ".join([self.getMDValue('title',generic="yes"), |
#logger(" ECHO_collection(getMDSimpleSearchField)",logging.INFO," ".join([self.getMDValue('title',generic="yes"), |
# self.getMDValue('author',generic="yes"), |
# self.getMDValue('author',generic="yes"), |
# self.getMDValue('year',generic="yes"),''])) |
# self.getMDValue('year',generic="yes"),''])) |
return "" |
return "" |
Line 1221 class ECHO_resource(CatalogAware,Folder,
|
Line 1364 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()) |
logger("ECHO_collection (getMDValue)", logging.INFO, "no_content type for %s"%self.getId()) |
ct="" |
ct="" |
|
|
#caching |
#caching |
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 1245 class ECHO_resource(CatalogAware,Folder,
|
Line 1392 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()) |
logger("ECHO (line 1069)",logging.ERROR,"no md hash for %s"%self.getId()) |
return "" |
return "" |
|
|
else: |
else: |
Line 1255 class ECHO_resource(CatalogAware,Folder,
|
Line 1402 class ECHO_resource(CatalogAware,Folder,
|
|
|
ret= self.metaDataHash.get(fieldNameTest,empty) |
ret= self.metaDataHash.get(fieldNameTest,empty) |
|
|
if type(ret) is StringType: |
return unicodify(ret) |
return ret.decode('utf-8') |
|
else: |
|
return ret |
|
|
|
getFieldValue=getMDValue #depricated |
getFieldValue=getMDValue #depricated |
|
|
Line 1270 class ECHO_resource(CatalogAware,Folder,
|
Line 1414 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 1315 class ECHO_resource(CatalogAware,Folder,
|
Line 1463 class ECHO_resource(CatalogAware,Folder,
|
self.REQUEST.RESPONSE.setHeader('Content-Type','text/xml') |
self.REQUEST.RESPONSE.setHeader('Content-Type','text/xml') |
return writeMetadata(self.metalink,self.metaDataHash) |
return writeMetadata(self.metalink,self.metaDataHash) |
|
|
|
def getMetaDataLink(self): |
|
"""get link to the meta data""" |
|
return self.metalink |
|
|
def changeECHO_resource(self,metalink,link,title,label,description,contentType,responsible,weight,coords=None,credits=None,RESPONSE=None): |
def changeECHO_resource(self,metalink,link,title,label,description,contentType,responsible,weight,coords=None,credits=None,RESPONSE=None): |
"""Aenderung der Properties""" |
"""Aenderung der Properties""" |
|
|
Line 1407 class ECHO_resource(CatalogAware,Folder,
|
Line 1559 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 1449 class ECHO_resource(CatalogAware,Folder,
|
Line 1602 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 1476 class ECHO_resource(CatalogAware,Folder,
|
Line 1629 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 1491 class ECHO_resource(CatalogAware,Folder,
|
Line 1644 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 1504 class ECHO_resource(CatalogAware,Folder,
|
Line 1657 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 1555 class ECHO_resource(CatalogAware,Folder,
|
Line 1708 class ECHO_resource(CatalogAware,Folder,
|
self.REQUEST.RESPONSE.write(fh) |
self.REQUEST.RESPONSE.write(fh) |
self.REQUEST.RESPONSE.close() |
self.REQUEST.RESPONSE.close() |
return |
return |
|
|
|
if getattr(self,'newViewer',''): #benutze den neuen viewer |
|
url=self.newViewer+'url='+self.metalink+"&mode=texttool" |
|
return self.REQUEST.RESPONSE.redirect(url) |
|
|
return self.REQUEST.RESPONSE.redirect(self.link) |
return self.REQUEST.RESPONSE.redirect(self.link) |
|
|
def startpage_html(self): |
def startpage_html(self): |
Line 1589 class ECHO_resource(CatalogAware,Folder,
|
Line 1747 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 1598 class ECHO_resource(CatalogAware,Folder,
|
Line 1756 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 1641 class ECHO_externalLink(Folder,ECHO_basi
|
Line 1799 class ECHO_externalLink(Folder,ECHO_basi
|
|
|
|
|
|
|
def __init__(self,id,link,title,label,description,contentType,responsible,credits,weight,coords): |
def __init__(self,id,link,title,label,description,contentType,responsible,credits,weight,coords,linkType): |
|
|
self.id = id |
self.id = id |
"""Festlegen der ID""" |
"""Festlegen der ID""" |
Line 1656 class ECHO_externalLink(Folder,ECHO_basi
|
Line 1814 class ECHO_externalLink(Folder,ECHO_basi
|
self.responsible=responsible |
self.responsible=responsible |
coordsnew=[ string.split(x,",") for x in coords] |
coordsnew=[ string.split(x,",") for x in coords] |
self.coords=coordsnew |
self.coords=coordsnew |
|
self.linkType = linkType # Linktypen 'otherPresentation','external' |
|
|
|
|
def ECHO_externalLink_config(self): |
def ECHO_externalLink_config(self): |
"""Main configuration""" |
"""Main configuration""" |
Line 1671 class ECHO_externalLink(Folder,ECHO_basi
|
Line 1831 class ECHO_externalLink(Folder,ECHO_basi
|
return pt() |
return pt() |
|
|
|
|
def changeECHO_externalLink(self,link,title,label,description,contentType,responsible,weight,coords=None,credits=None,RESPONSE=None): |
def changeECHO_externalLink(self,link,title,label,description,contentType,responsible,weight,coords=None,credits=None,RESPONSE=None,linkType='otherPresentation'): |
"""Aenderung der Properties""" |
"""Aenderung der Properties""" |
setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight) |
setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight) |
|
|
self.link=link |
self.link=link |
|
self.linkType = linkType |
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
|
def getLinkType(self): |
|
""" return linkType """ |
|
if hasattr(self,"linkType"): |
|
return self.linkType |
|
else : |
|
return 'otherPresentation' |
|
|
manage_options = Folder.manage_options+( |
def setLinkType(self,type): |
|
""" set linkType """ |
|
self.linkType = type |
|
|
|
def checkLink(self): |
|
""" returns tuple (isWorking,Error) """ |
|
try: |
|
urllib2.urlopen(self.link) |
|
return (True, '') |
|
except urllib2.HTTPError, e: |
|
return (False, e.code) |
|
except urllib2.URLError, e: |
|
return (False, str(e.reason)) |
|
except: |
|
return (False, 'unknown Error') |
|
|
|
|
|
manage_options = ( |
{'label':'Main Config','action':'ECHO_externalLink_config'}, |
{'label':'Main Config','action':'ECHO_externalLink_config'}, |
{'label':'Graphic Coords','action':'ECHO_graphicEntry'}, |
{'label':'Graphic Coords','action':'ECHO_graphicEntry'}, |
) |
)+Folder.manage_options |
|
|
|
|
def index_html(self): |
def index_html(self): |
Line 1691 class ECHO_externalLink(Folder,ECHO_basi
|
Line 1875 class ECHO_externalLink(Folder,ECHO_basi
|
|
|
return self.REQUEST.RESPONSE.redirect(self.link) |
return self.REQUEST.RESPONSE.redirect(self.link) |
|
|
|
|
def manage_addECHO_externalLinkForm(self): |
def manage_addECHO_externalLinkForm(self): |
"""Form for external Links""" |
"""Form for external Links""" |
pt=zptFile(self, 'zpt/AddECHO_externalLinkForm.zpt') |
pt=zptFile(self, 'zpt/AddECHO_externalLinkForm.zpt') |
return pt() |
return pt() |
|
|
|
|
def manage_addECHO_externalLink(self,id,title,label,description,contentType,responsible,link,weight,coords=None,credits=None,RESPONSE=None): |
def manage_addECHO_externalLink(self,id,title,label,description,contentType,responsible,link,weight,coords=None,credits=None,RESPONSE=None,linkType='otherPresentation'): |
"""Add an external Link""" |
"""Add an external Link""" |
|
|
newObj=ECHO_externalLink(id,link,title,label,description,contentType,responsible,credits,weight,coords) |
newObj=ECHO_externalLink(id,link,title,label,description,contentType,responsible,credits,weight,coords,linkType) |
|
|
self._setObject(id,newObj) |
self._setObject(id,newObj) |
|
|
Line 1753 class ECHO_link(ECHO_externalLink):
|
Line 1938 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 1785 def manage_addECHO_linkForm(self):
|
Line 2034 def manage_addECHO_linkForm(self):
|
return pt() |
return pt() |
|
|
|
|
def manage_addECHO_link(self,id,title,label,description="",contentType="",responsible="",link="",weight="",coords=[],credits=None,RESPONSE=None): |
def manage_addECHO_link(self,id,title,label,description="",contentType="",responsible="",link="",weight="",coords=[],credits=None,linkType="external",RESPONSE=None): |
"""Add an external Link""" |
"""Add an external Link""" |
|
|
newObj=ECHO_link(id,link,title,label,description,contentType,responsible,credits,weight,coords) |
newObj=ECHO_link(id,link,title,label,description,contentType,responsible,credits,weight,coords,linkType) |
|
|
self._setObject(id,newObj) |
self._setObject(id,newObj) |
|
|
Line 1811 class ECHO_collection(CatalogAware, Fold
|
Line 2060 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 1862 class ECHO_collection(CatalogAware, Fold
|
Line 2188 class ECHO_collection(CatalogAware, Fold
|
|
|
if obj.meta_type=="ECHO_mapText": |
if obj.meta_type=="ECHO_mapText": |
if splitted[1]=="en": |
if splitted[1]=="en": |
obj.locale_en.pt_edit(REQUEST.form[key],None) |
obj.locale_en.pt_edit(REQUEST.form[key],obj.locale_en.content_type) |
else: |
else: |
obj.pt_edit(REQUEST.form[key],None) |
obj.pt_edit(REQUEST.form[key],obj.content_type) |
else: |
else: |
text=obj.ZopeFind(obj,obj_metatypes=['ECHO_mapText']) |
text=obj.ZopeFind(obj,obj_metatypes=['ECHO_mapText']) |
if splitted[1]=="en": |
if splitted[1]=="en": |
|
|
text[0][1].locale_en.pt_edit(REQUEST.form[key],None) |
text[0][1].locale_en.pt_edit(REQUEST.form[key],text[0][1].locale_en.content_type) |
else: |
else: |
text[0][1].pt_edit(REQUEST.form[key],None) |
text[0][1].pt_edit(REQUEST.form[key],text[0][1].content_type) |
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
Line 2096 class ECHO_collection(CatalogAware, Fold
|
Line 2422 class ECHO_collection(CatalogAware, Fold
|
else: |
else: |
return None |
return None |
|
|
|
def changeViewer(self,newViewer,REQUEST=None,RESPONSE=None): |
|
"""changes all ressources to the newViewer""" |
|
|
|
resources=self.ZopeFind(self,obj_metatypes=['ECHO_resource'],search_sub=1) |
|
if RESPONSE is not None: |
|
RESPONSE.write("<html><body>") |
|
|
|
for resource in resources: |
|
|
|
done,msg=resource[1].changeViewer(newViewer) |
|
if done: |
|
if RESPONSE is not None: |
|
RESPONSE.write("<p>OK: %s"%resource[0]) |
|
else: |
|
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)) |
|
|
|
|
|
|
|
if RESPONSE is not None: |
|
RESPONSE.write("<p>Done</p></body></html>") |
|
|
def changeViewerTemplateSets(self,project,xslt,thumbtemplate,topbar,digiLibTemplate,digiliburlprefix,RESPONSE=None): |
def changeViewerTemplateSets(self,project,xslt,thumbtemplate,topbar,digiLibTemplate,digiliburlprefix,RESPONSE=None): |
"""change the templates""" |
"""change the templates""" |
|
|
Line 2145 class ECHO_collection(CatalogAware, Fold
|
Line 2493 class ECHO_collection(CatalogAware, Fold
|
if ret and RESPONSE: |
if ret and RESPONSE: |
RESPONSE.write("ok: %s\n"%txt) |
RESPONSE.write("ok: %s\n"%txt) |
|
|
#zLOG.LOG("ECHO (copyTitleToInfoXMLFolder)",zLOG.INFO,txt) |
#logger("ECHO (copyTitleToInfoXMLFolder)",logging.INFO,txt) |
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.write("done!\n") |
RESPONSE.write("done!\n") |
RESPONSE.close() |
RESPONSE.close() |
Line 2193 class ECHO_collection(CatalogAware, Fold
|
Line 2541 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 2221 class ECHO_collection(CatalogAware, Fold
|
Line 2571 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 2260 class ECHO_collection(CatalogAware, Fold
|
Line 2611 class ECHO_collection(CatalogAware, Fold
|
manage_addECHO_resource(self,id,title,label,description,responsible,link,metalink,weight,credits=None,coords=None,RESPONSE=None) |
manage_addECHO_resource(self,id,title,label,description,responsible,link,metalink,weight,credits=None,coords=None,RESPONSE=None) |
return "done" |
return "done" |
except: |
except: |
|
logging.error("ECHOcollection: (AddResource): %s %s"%sys.exc_info()[0:2]) |
|
return None |
|
|
|
def addResourceAndCreateLabelAndTitle(self,id,title,label,description,contentType,responsible,link,metalink,weight,credits=None,coords=None,RESPONSE=None): |
|
"""SSS""" |
|
ret = self.addResource(id,title,label,description,contentType,responsible,link,metalink,weight,credits,coords,RESPONSE) |
|
if ret is None: |
return None |
return None |
|
|
|
try: |
|
server2=getattr(self,id) |
|
server2.copyIndex_meta2echo_resource() |
|
server2.generate_label() |
|
server2.generate_title() |
|
except: |
|
logging.error("An Error occured adding the resource A\n %s %s"%sys.exc_info()[0:2]) |
|
return None |
|
return "done" |
def getSecondaryLink(self): |
def getSecondaryLink(self): |
"""secondary link""" |
"""secondary link""" |
try: |
try: |
Line 2303 class ECHO_collection(CatalogAware, Fold
|
Line 2670 class ECHO_collection(CatalogAware, Fold
|
ret="""<?xml version="1.0" encoding="utf-8" ?>""" |
ret="""<?xml version="1.0" encoding="utf-8" ?>""" |
return ret+"<collection>"+getCollection(self,pwstr=pwstr)+"</collection>" |
return ret+"<collection>"+getCollection(self,pwstr=pwstr)+"</collection>" |
|
|
def createAllJSAreas(self): |
def createAllJSAreas(self,mapColTypes=None): |
"""create area calls for JavaScript""" |
"""create area calls for JavaScript""" |
areas = self.getAllMapAreas() |
areas = self.getAllMapAreas(mapColTypes=mapColTypes) |
return self.createJSAreas(areas) |
return self.createJSAreas(areas) |
|
|
|
|
Line 2355 class ECHO_collection(CatalogAware, Fold
|
Line 2722 class ECHO_collection(CatalogAware, Fold
|
return ECHO_rerenderLinksMD(self,obj,types) |
return ECHO_rerenderLinksMD(self,obj,types) |
|
|
|
|
def __init__(self,id,title,label,description="",contentType="",responsible="",credits="",weight="",sortfield="",coords=[],secondaryLinkTitle="",secondaryLink="",imageTag="",bgcolour=""): |
def __init__(self,id,title,label,description="",contentType="",responsible="",credits="",weight="",sortfield="",coords=[],secondaryLinkTitle="",secondaryLink="",imageTag="",bgcolour="",isVisible=True): |
|
|
self.id = id |
self.id = id |
"""Festlegen der ID""" |
"""Festlegen der ID""" |
Line 2373 class ECHO_collection(CatalogAware, Fold
|
Line 2740 class ECHO_collection(CatalogAware, Fold
|
self.secondaryLinkTitle=secondaryLinkTitle |
self.secondaryLinkTitle=secondaryLinkTitle |
self.secondaryLink=secondaryLink |
self.secondaryLink=secondaryLink |
self.bgcolour=bgcolour |
self.bgcolour=bgcolour |
|
self.isVisible=isVisible |
|
|
|
|
manage_options = Folder.manage_options+ Cacheable.manage_options+( |
manage_options = Folder.manage_options+ Cacheable.manage_options+( |
Line 2382 class ECHO_collection(CatalogAware, Fold
|
Line 2750 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 2416 class ECHO_collection(CatalogAware, Fold
|
Line 2785 class ECHO_collection(CatalogAware, Fold
|
|
|
|
|
security.declarePublic('changeECHO_collection') |
security.declarePublic('changeECHO_collection') |
def changeECHO_collection(self,title,label,description,contentType,responsible,weight,secondaryLink,secondaryLinkTitle,credits=None,sortfield="weight",coords=None,RESPONSE=None,imageTag="",bgcolour="",location=None,isAlwaysClickable=None,prefix="",suffix=""): |
def changeECHO_collection(self,title,label,description,contentType,responsible,weight,secondaryLink,secondaryLinkTitle,credits=None,sortfield="weight",coords=None,RESPONSE=None,imageTag="",bgcolour="",location=None,isAlwaysClickable=None,prefix="",suffix="",isVisible=True): |
"""Aenderung der Properties""" |
"""Aenderung der Properties""" |
|
|
self.secondaryLink=secondaryLink |
self.secondaryLink=secondaryLink |
Line 2427 class ECHO_collection(CatalogAware, Fold
|
Line 2796 class ECHO_collection(CatalogAware, Fold
|
self.isAlwaysClickable=isAlwaysClickable |
self.isAlwaysClickable=isAlwaysClickable |
self.prefix=prefix[0:] |
self.prefix=prefix[0:] |
self.suffix=suffix[0:] |
self.suffix=suffix[0:] |
|
self.setIsVisible(isVisible) |
|
|
setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight) |
setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight) |
|
|
Line 2527 class ECHO_collection(CatalogAware, Fold
|
Line 2897 class ECHO_collection(CatalogAware, Fold
|
"""javascript""" |
"""javascript""" |
return sendFile(self, 'js/hl_add.js', 'text/plain') |
return sendFile(self, 'js/hl_add.js', 'text/plain') |
|
|
def getAllMapAreas(self,mapColTypes=['ECHO_collection','ECHO_resource','ECHO_link','ECHO_externalLink']): |
def getAllMapAreas(self,mapColTypes=None): |
"""Give list of coordinates""" |
"""Give list of coordinates""" |
|
if mapColTypes is None: |
|
mapColTypes=['ECHO_collection','ECHO_resource','ECHO_link','ECHO_externalLink'] |
|
|
areas=[] |
areas=[] |
for entry in self.getSubCols(subColTypes=mapColTypes): |
for entry in self.getSubCols(subColTypes=mapColTypes): |
Line 2564 def manage_addECHO_collectionForm(self):
|
Line 2936 def manage_addECHO_collectionForm(self):
|
return pt() |
return pt() |
|
|
|
|
def manage_addECHO_collection(self,id,title,label,description="",contentType="",responsible="",weight=0,sortfield="weight",coords="",secondaryLinkTitle="",secondaryLink="",credits=None,RESPONSE=None,imageTag="",bgcolour=""): |
def manage_addECHO_collection(self,id,title,label,description="",contentType="",responsible="",weight=0,sortfield="weight",coords="",secondaryLinkTitle="",secondaryLink="",credits=None,RESPONSE=None,imageTag="",bgcolour="",isVisible=True): |
"""add a echo collection""" |
"""add a echo collection""" |
|
|
|
|
newObj=ECHO_collection(id,title,label,description,contentType,responsible,credits,weight,sortfield,coords,secondaryLinkTitle=secondaryLinkTitle,secondaryLink=secondaryLink,imageTag=imageTag,bgcolour="") |
newObj=ECHO_collection(id,title,label,description,contentType,responsible,credits,weight,sortfield,coords,secondaryLinkTitle=secondaryLinkTitle,secondaryLink=secondaryLink,imageTag=imageTag,bgcolour="",isVisible=isVisible) |
|
|
self._setObject(id,newObj) |
self._setObject(id,newObj) |
|
|
Line 3179 class ECHO_root(Folder,Persistent,Implic
|
Line 3551 class ECHO_root(Folder,Persistent,Implic
|
"""ret attribute if existing""" |
"""ret attribute if existing""" |
try: |
try: |
|
|
return getattr(found,field).decode('ascii','ignore') |
return getattr(found,field)#.decode('utf-8','ignore') |
except: |
except: |
|
logging.error("can't: decode: %s"%repr(field)) |
|
logging.error(" %s %s"%(sys.exc_info()[0],sys.exc_info()[1])) |
return "" |
return "" |
|
|
security.declarePublic('getImageTag') |
security.declarePublic('getImageTag') |
Line 3417 class ECHO_root(Folder,Persistent,Implic
|
Line 3791 class ECHO_root(Folder,Persistent,Implic
|
|
|
def formatAscii(self,str,url=None): |
def formatAscii(self,str,url=None): |
"""ersetze ascii umbrueche durch <br>""" |
"""ersetze ascii umbrueche durch <br>""" |
#url=None |
|
|
if not str: |
|
return "" |
|
|
if url: |
if url: |
|
|
retStr="" |
retStr="" |
Line 3429 class ECHO_root(Folder,Persistent,Implic
|
Line 3806 class ECHO_root(Folder,Persistent,Implic
|
retStr+="""<a href="%s">%s</a><br/>"""%(strUrl,word) |
retStr+="""<a href="%s">%s</a><br/>"""%(strUrl,word) |
str=retStr |
str=retStr |
if str: |
if str: |
return re.sub(r"[\n]","<br/>",str) |
str = re.sub(r"[\n]","<br/>",str) |
|
return unicodify(str) |
else: |
else: |
return "" |
return u"" |
|
|
link2html=vlp_xmlhelpers.link2html |
link2html=vlp_xmlhelpers.link2html |
|
related2html=vlp_xmlhelpers.related2html |
|
|
xml2html=vlp_xmlhelpers.xml2html |
xml2html=vlp_xmlhelpers.xml2html |
|
|
Line 3466 class ECHO_root(Folder,Persistent,Implic
|
Line 3845 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 3564 class ECHO_root(Folder,Persistent,Implic
|
Line 3946 class ECHO_root(Folder,Persistent,Implic
|
self.REQUEST.RESPONSE.setHeader("Content-Type", "text/xml") |
self.REQUEST.RESPONSE.setHeader("Content-Type", "text/xml") |
self.REQUEST.RESPONSE.write(ret) |
self.REQUEST.RESPONSE.write(ret) |
|
|
|
def getCollectionsXML(self,viewerType=None,filter=None): |
|
"""gebe collections aus""" |
|
ret="""<?xml version="1.0" ?> |
|
<index>""" |
|
for resource in self.ZopeFind(self,obj_metatypes=['ECHO_collection','ECHO_group'],search_sub=1): |
|
|
|
echo_url=resource[1].absolute_url() |
|
|
|
ret+="""\n<collection echoLink="%s"/>"""%urllib.quote(echo_url,safe='/:?') |
|
ret +="""\n</index>""" |
|
|
|
self.REQUEST.RESPONSE.setHeader("Content-Type", "text/xml") |
|
self.REQUEST.RESPONSE.write(ret) |
|
|
def getFullTextsXML(self,viewerType=None,filter=None): |
def getFullTextsXML(self,viewerType=None,filter=None): |
"""gebe all ressourcen aus""" |
"""gebe all ressourcen aus""" |
ret="""<?xml version="1.0" ?> |
ret="""<?xml version="1.0" ?> |
Line 3787 class ECHO_linkList(ZopePageTemplate,ECH
|
Line 4183 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 3798 class ECHO_linkList(ZopePageTemplate,ECH
|
Line 4194 class ECHO_linkList(ZopePageTemplate,ECH
|
self.ZBindings_edit(self._default_bindings) |
self.ZBindings_edit(self._default_bindings) |
if text is None: |
if text is None: |
text = '' |
text = '' |
|
if content_type is None: |
|
content_type = self.content_type |
self.pt_edit(text, contentType) |
self.pt_edit(text, contentType) |
|
|
|
|
Line 3898 def manage_addECHO_support(self, id,inst
|
Line 4296 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""" |