version 1.129, 2004/06/24 12:23:05
|
version 1.191, 2004/11/28 21:56:07
|
Line 14 import re
|
Line 14 import re
|
import os |
import os |
import OFS.Image |
import OFS.Image |
from types import * |
from types import * |
|
from OFS.Cache import Cacheable |
from OFS.Image import Image |
from OFS.Image import Image |
from Globals import DTMLFile |
from Globals import DTMLFile |
from OFS.Folder import Folder |
from OFS.Folder import Folder |
Line 28 from Products.PageTemplates.PageTemplate
|
Line 29 from Products.PageTemplates.PageTemplate
|
from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate |
from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate |
from Globals import Persistent, package_home |
from Globals import Persistent, package_home |
from Acquisition import Implicit |
from Acquisition import Implicit |
from ECHO_helpers import displayTypes |
|
|
|
|
import urllib |
|
import smtplib |
|
import time |
|
from Ft.Xml.Domlette import NonvalidatingReader |
|
from Ft.Xml.Domlette import PrettyPrint |
|
from Ft.Xml import EMPTY_NAMESPACE |
|
|
|
import Ft.Xml.XPath |
|
import cStringIO |
|
import zLOG |
|
|
try: |
try: |
from psycopg import libpq |
from psycopg import libpq |
Line 45 import urllib
|
Line 55 import urllib
|
import xml.dom.minidom |
import xml.dom.minidom |
from ECHO_graphicalOverview import javaHandler,javaScriptMain |
from ECHO_graphicalOverview import javaHandler,javaScriptMain |
import ECHO_helpers |
import ECHO_helpers |
|
from ECHO_helpers import * |
|
from ECHO_language import * |
|
|
def getCopyrightsFromForm(self,argv): |
|
medias={} |
|
partners={} |
|
copyrights={} |
|
|
|
copyrightsFinal=[] |
|
for arg in argv.keys(): |
|
|
|
if arg[0:5]=='media': |
|
nm=int(arg[5:]) |
|
medias[nm]=argv[arg] |
|
elif arg[0:5]=='partn': |
|
nm=int(arg[5:]) |
|
partners[nm]=argv[arg] |
|
elif arg[0:5]=='copyr': |
|
nm=int(arg[5:]) |
|
copyrights[nm]=argv[arg] |
|
|
|
|
|
|
|
copyrightsList=[(medias[nm],partners[nm],copyrights[nm]) for nm in medias.keys()] |
|
for copyright in copyrightsList: |
|
|
|
if copyright[2]=='institution0000': |
|
copyrightsFinal.append((copyright[0],copyright[1],self.getPartnerCopyright(copyright[1],''))) |
|
else: |
|
if not copyright[0]=='': |
|
copyrightsFinal.append(copyright) |
|
|
|
|
|
return copyrightsFinal |
|
|
|
#List of different types for the graphical linking viewer |
|
viewClassificationListMaster=['view point','area'] |
|
|
|
|
|
def checkDiffs(self,metadict): |
|
"""check differences""" |
|
|
|
|
|
|
|
|
|
def NoneToEmpty(obj): |
|
if obj: |
|
return obj |
|
else: |
|
return "" |
|
|
|
|
|
|
|
diffs={} |
|
|
|
tags=self.findTagsFromMapping(self.contentType) |
|
self.referencetypes=tags[2] |
|
self.fields=tags[3] |
|
|
|
|
|
for field in tags[1]: |
|
try: |
|
if (NoneToEmpty(self.getFieldValue(self.getFieldTag(tags,field)))==metadict[self.getFieldTag(tags,field)]): |
|
diffs[self.getFieldTag(tags,field)]=1 |
|
else: |
|
|
|
diffs[self.getFieldTag(tags,field)]=0 |
|
except: |
|
diffs[self.getFieldTag(tags,field)]=0 |
|
|
|
return diffs |
|
|
|
def content_html(self,type): |
|
"""template fuer content""" |
|
#templates = self.ZopeFind(self.aq_parent,obj_ids=[type+"_template"]) |
|
# |
|
#if templates: |
|
# return templates[0][1]() |
|
|
|
if hasattr(self,type+"_template"): |
|
obj=getattr(self,type+"_template") |
|
return obj() |
|
else: |
|
pt=PageTemplateFile('Products/ECHO_content/zpt/ECHO_%s_template_standard.zpt'%type).__of__(self) |
|
pt.content_type="text/html" |
|
return pt() |
|
|
|
def toList(field): |
|
"""Einzelfeld in Liste umwandeln""" |
|
if type(field)==StringType: |
|
return [field] |
|
else: |
|
return field |
|
|
|
def getText(nodelist): |
#regexp for extracting elements from xml |
|
patternTXT=r"<\s*txt.*?>(.*?)</txt>" |
|
regexpTXT = re.compile(patternTXT, re.IGNORECASE + re.DOTALL) |
|
patternPage=r"<\s*page.*?>(.*?)</page>" |
|
regexpPage = re.compile(patternPage, re.IGNORECASE + re.DOTALL) |
|
|
rc = "" |
|
for node in nodelist: |
|
if node.nodeType == node.TEXT_NODE: |
|
rc = rc + node.data |
|
return rc |
|
|
|
|
|
def sendFile(self, filename, type): |
|
"""sends an object or a local file (in the product) as response""" |
|
paths = filename.split('/') |
|
object = self |
|
# look for an object called filename |
|
for path in paths: |
|
if hasattr(object, path): |
|
object = getattr(object, path) |
|
else: |
|
object = None |
|
break |
|
if object: |
|
# if the object exists then send it |
|
return object.index_html(self.REQUEST.REQUEST, self.REQUEST.RESPONSE) |
|
else: |
|
# send a local file with the given content-type |
|
fn = os.path.join(package_home(globals()), filename) |
|
self.REQUEST.RESPONSE.setHeader("Content-Type", type) |
|
self.REQUEST.RESPONSE.write(file(fn).read()) |
|
return |
|
|
|
class BrowserCheck: |
|
"""check the browsers request to find out the browser type""" |
|
|
|
def __init__(self, zope): |
|
self.ua = zope.REQUEST.get_header("HTTP_USER_AGENT") |
|
self.isN4 = (string.find(self.ua, 'Mozilla/4.') > -1) and (string.find(self.ua, 'MSIE') < 0) |
|
self.isIE = string.find(self.ua, 'MSIE') > -1 |
|
self.nav = self.ua[string.find(self.ua, '('):] |
|
ie = string.split(self.nav, "; ")[1] |
|
if string.find(ie, "MSIE") > -1: |
|
self.versIE = string.split(ie, " ")[1] |
|
self.isMac = string.find(self.ua, 'Macintosh') > -1 |
|
self.isWin = string.find(self.ua, 'Windows') > -1 |
|
self.isIEWin = self.isIE and self.isWin |
|
self.isIEMac = self.isIE and self.isMac |
|
|
|
|
|
def writeMetadata(url,metadict,project=None,startpage=None,xslt=None,thumbtemplate=None,topbar=None,digiLibTemplate=None): |
|
"""Einlesen der Metadaten und und erstellen des geaenderten XML file""" |
|
def updateTextToolNode(tag,value): |
|
print dom,tag,value |
|
metanode=dom.getElementsByTagName('texttool')[0] |
|
try: |
|
nodeOld=metanode.getElementsByTagName(tag) |
|
except: |
|
nodeOld=None |
|
|
|
if nodeOld: |
|
metanode.removeChild(nodeOld[0]).unlink() |
|
|
|
node=dom.createElement(tag) |
|
nodetext=dom.createTextNode(value) |
|
node.appendChild(nodetext) |
|
metanode.appendChild(node) |
|
|
|
|
|
try: |
|
geturl="" |
|
for line in urllib.urlopen(url).readlines(): |
|
geturl=geturl+line |
|
|
|
|
|
except: |
|
return (None,"Cannot open: "+url) |
|
|
|
try: |
|
dom=xml.dom.minidom.parseString(geturl) |
|
except: |
|
return (None,"Cannot parse: "+url+"<br>"+geturl) |
|
|
|
metanodes=dom.getElementsByTagName('bib') |
|
|
|
if not metanodes: |
|
metanodes=dom.getElementsByTagName('archimedes') |
|
|
|
metanode=metanodes[0] |
|
|
|
for metaData in metadict.keys(): |
|
|
|
try: |
|
nodeOld=metanode.getElementsByTagName(metaData) |
|
except: |
|
nodeOld=None |
|
|
|
if nodeOld: |
|
metanode.removeChild(nodeOld[0]).unlink() |
|
else: |
|
# try also old writing rule - instead of _: |
|
try: |
|
nodeOld=metanode.getElementsByTagName(re.sub('_','-',metaData)) |
|
except: |
|
nodeOld=None |
|
|
|
if nodeOld: |
|
metanode.removeChild(nodeOld[0]).unlink() |
|
|
|
metanodeneu=dom.createElement(metaData) |
|
try: |
|
metanodetext=dom.createTextNode(unicode(metadict[metaData],"utf-8")) |
|
except: |
|
metanodetext=dom.createTextNode(metadict[metaData].encode('utf-8')) |
|
metanodeneu.appendChild(metanodetext) |
|
metanode.appendChild(metanodeneu) |
|
|
|
|
|
|
|
|
|
|
|
if project: |
|
updateTextToolNode('project',project) |
|
|
|
if startpage: |
|
updateTextToolNode('startpage',startpage) |
|
|
|
if topbar: |
|
updateTextToolNode('toptemplate',topbar) |
|
|
|
if thumbtemplate: |
|
updateTextToolNode('thumbtemplate',thumbtemplate) |
|
|
|
if xslt: |
|
updateTextToolNode('xslt',xslt) |
|
|
|
|
|
|
|
return dom.toxml().encode('utf-8') |
|
|
|
|
|
|
|
def readMetadata(url): |
|
"""Methode zum Auslesen der Metadateninformation zu einer Resource |
|
Vorerst noch Typ bib""" |
|
|
|
metadict={} |
|
try: |
|
geturl="" |
|
for line in urllib.urlopen(url).readlines(): |
|
geturl=geturl+line |
|
|
|
|
|
except: |
|
return (None,"Cannot open: "+url) |
|
|
|
try: |
|
dom=xml.dom.minidom.parseString(geturl) |
|
except: |
|
return (None,"Cannot parse: "+url+"<br>"+geturl) |
|
|
|
metanode=dom.getElementsByTagName('bib') |
|
metadict['bib_type']='Book' |
|
if len(metanode)==0: |
|
metanode=dom.getElementsByTagName('archimedes') |
|
metadict['bib_type']='Archimedes' |
|
|
|
|
|
if not len(metanode)==0: |
|
metacontent=metanode[0].childNodes |
|
|
|
try: |
|
metadict['bib_type']=getText(dom.getElementsByTagName('bib')[0].attributes['type'].childNodes) |
|
except: |
|
"""nothing""" |
|
|
|
for node in metacontent: |
|
try: |
|
#print urllib.unquote(getText(node.childNodes)),getText(node.childNodes) |
|
metadict[re.sub('-','_',node.tagName.lower())]=urllib.unquote(getText(node.childNodes)) |
|
except: |
|
"""nothing""" |
|
|
|
|
|
return metadict,"" |
|
|
|
|
|
def setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight,coordstrs,viewClassification=""): |
def setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight,coordstrs,viewClassification=""): |
Line 352 def setECHO_collectionInformation(self,t
|
Line 98 def setECHO_collectionInformation(self,t
|
|
|
self.coords=coords[0:] |
self.coords=coords[0:] |
|
|
class ECHO_copyright(Folder): |
class ECHO_copyright(Folder,ECHO_basis): |
"""Copyright informationen""" |
"""Copyright informationen""" |
meta_type="ECHO_copyright" |
meta_type="ECHO_copyright" |
|
|
Line 372 class ECHO_copyright(Folder):
|
Line 118 class ECHO_copyright(Folder):
|
{'label':'Main Config','action':'ECHO_copyright_configForm'}, |
{'label':'Main Config','action':'ECHO_copyright_configForm'}, |
) |
) |
|
|
|
|
def ECHO_copyright_configForm(self): |
def ECHO_copyright_configForm(self): |
"""change form""" |
"""change form""" |
pt=PageTemplateFile('Products/ECHO_content/zpt/ChangeECHO_copyright').__of__(self) |
pt=PageTemplateFile('Products/ECHO_content/zpt/ChangeECHO_copyright').__of__(self) |
Line 407 def manage_addECHO_copyright(self, id,ti
|
Line 154 def manage_addECHO_copyright(self, id,ti
|
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
class ECHO_layoutTemplate(ZopePageTemplate): |
class ECHO_layoutTemplate(ZopePageTemplate,ECHO_basis): |
"""Create a layout Template for different purposes""" |
"""Create a layout Template for different purposes""" |
|
|
meta_type="ECHO_layoutTemplate" |
meta_type="ECHO_layoutTemplate" |
Line 430 class ECHO_layoutTemplate(ZopePageTempla
|
Line 177 class ECHO_layoutTemplate(ZopePageTempla
|
|
|
def manage_addECHO_layoutTemplateForm(self): |
def manage_addECHO_layoutTemplateForm(self): |
"""Form for adding""" |
"""Form for adding""" |
pt=PageTemplateFile('Products/ECHO_content/zpt/AddECHO_layoutTemplate.zpt').__of__(self) |
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt/AddECHO_layoutTemplate.zpt')).__of__(self) |
return pt() |
return pt() |
|
|
from urllib import quote |
from urllib import quote |
Line 475 def manage_addECHO_layoutTemplate(self,
|
Line 222 def manage_addECHO_layoutTemplate(self,
|
REQUEST.RESPONSE.redirect(u+'/manage_main') |
REQUEST.RESPONSE.redirect(u+'/manage_main') |
return '' |
return '' |
|
|
class ECHO_resource(Folder,Persistent): |
class ECHO_fullText(ZopePageTemplate,ECHO_basis,ECHO_language): |
|
"""echo fulltext in xml""" |
|
|
|
meta_type="ECHO_fullText" |
|
|
|
|
|
def getPage(self,nr='1'): |
|
"""get page n""" |
|
dom=xml.dom.minidom.parseString(self()) |
|
pages=dom.getElementsByTagName('page') |
|
|
|
return pages[int(nr)-1].toxml('utf-8') |
|
|
|
# Product registration and Add support |
|
manage_addECHO_fullTextForm = PageTemplateFile( |
|
'zpt/AddECHO_fullText.zpt', globals()) |
|
|
|
from urllib import quote |
|
|
|
def manage_addECHO_fullText(self, id, title=None, text=None, |
|
REQUEST=None, submit=None): |
|
"Add a Page Template with optional file content." |
|
|
|
id = str(id) |
|
if REQUEST is None: |
|
self._setObject(id, ECHO_fullText(id, text)) |
|
ob = getattr(self, id) |
|
if title: |
|
ob.pt_setTitle(title) |
|
return ob |
|
else: |
|
file = REQUEST.form.get('file') |
|
headers = getattr(file, 'headers', None) |
|
if headers is None or not file.filename: |
|
zpt = ECHO_fullText(id) |
|
else: |
|
zpt = ECHO_fullText(id, file, headers.get('content_type')) |
|
|
|
self._setObject(id, zpt) |
|
|
|
try: |
|
u = self.DestinationURL() |
|
except AttributeError: |
|
u = REQUEST['URL1'] |
|
|
|
if submit == " Add and Edit ": |
|
u = "%s/%s" % (u, quote(id)) |
|
REQUEST.RESPONSE.redirect(u+'/manage_main') |
|
return '' |
|
|
|
class ECHO_resource(Folder,Persistent,ECHO_basis): |
"""ECHO Ressource""" |
"""ECHO Ressource""" |
security=ClassSecurityInfo() |
security=ClassSecurityInfo() |
meta_type='ECHO_resource' |
meta_type='ECHO_resource' |
Line 484 class ECHO_resource(Folder,Persistent):
|
Line 281 class ECHO_resource(Folder,Persistent):
|
|
|
getSubCols = ECHO_helpers.getSubCols |
getSubCols = ECHO_helpers.getSubCols |
|
|
|
security.declareProtected('View','index_html') |
|
|
|
def getRDF(self,urn=None): |
|
"""rdf""" |
|
ret=getRDFDescription(self,self.link,urn=urn) |
|
return ret+self.createSubElementRDF(urn=urn) |
|
|
|
|
|
def getAccessRightSelectorHTML(self,outlook="select"): |
|
"""htmlselector""" |
|
values=['free','mpiwg'] |
|
|
|
if outlook=="select": |
|
ret="""<select name="%s">"""%self.getId() |
|
|
|
for value in values: |
|
if value==self.getAccessRightMD(): |
|
ret+="<option selected>%s</option>"%value |
|
else: |
|
ret+="<option>%s</option>"%value |
|
return ret+"</select>" |
|
|
|
else: |
|
ret="" |
|
for value in values: |
|
|
|
if value==self.getAccessRightMD(): |
|
ret+="""<input type="radio" name="%s" value="%s" checked>%s"""%(self.getId(),value,value) |
|
else: |
|
ret+="""<input type="radio" name="%s" value="%s">%s"""%(self.getId(),value,value) |
|
return ret |
|
|
|
|
|
|
|
def getAccessRightMD(self): |
|
"""set accessright""" |
|
url=self.metalink |
|
|
|
try: |
|
geturl="" |
|
for line in ECHO_helpers.urlopen(url).readlines(): |
|
geturl=geturl+line |
|
|
|
|
|
except: |
|
return (None,"Cannot open: "+url) |
|
|
|
try: |
|
dom=xml.dom.minidom.parseString(geturl) |
|
root=dom.getElementsByTagName('resource')[0] |
|
except: |
|
return (None,"Cannot parse: "+url+"<br>"+geturl) |
|
|
|
internal=dom.getElementsByTagName('internal') |
|
if internal: |
|
institution=dom.getElementsByTagName('institution') |
|
return getText(institution[0].childNodes) |
|
|
|
free=dom.getElementsByTagName('free') |
|
if free: |
|
return "free" |
|
|
|
return "free" #default free |
|
|
|
def changeAccessRightMD(self,accessright,RESPONSE=None): |
|
"""change the rights""" |
|
|
|
params="accessright=%s"%accessright |
|
|
|
|
|
#print ECHO_helpers.urlopen(self.absolute_url()+'/setAccessRightXML'+'?'+params).read() |
|
|
|
|
|
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()+'/setAccessRightXML'+urllib.quote('?'+params))).read() |
|
|
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
|
|
def setAccessRightXML(self,accessright): |
|
"""set accessright""" |
|
url=self.metalink |
|
|
|
try: |
|
geturl="" |
|
for line in ECHO_helpers.urlopen(url).readlines(): |
|
geturl=geturl+line |
|
|
|
|
|
except: |
|
return (None,"Cannot open: "+url) |
|
|
|
try: |
|
dom=xml.dom.minidom.parseString(geturl) |
|
root=dom.getElementsByTagName('resource')[0] |
|
except: |
|
return (None,"Cannot parse: "+url+"<br>"+geturl) |
|
|
|
metanodes=dom.getElementsByTagName('access-conditions') |
|
|
|
if not metanodes: |
|
nodenew=dom.createElement('access-conditions') |
|
root.appendChild(nodenew) |
|
metanode=nodenew |
|
else: |
|
metanode=metanodes[0] |
|
|
|
accesses=metanode.getElementsByTagName('access') |
|
|
|
if not accesses: |
|
nodenew2=dom.createElement('access') |
|
metanode.appendChild(nodenew2) |
|
metanode2=nodenew2 |
|
else: |
|
metanode2=accesses[0] |
|
|
|
internal=metanode.getElementsByTagName('internal') |
|
|
|
if internal: |
|
metanode2.removeChild(internal[0]).unlink() |
|
|
|
free=metanode.getElementsByTagName('free') |
|
|
|
if free: |
|
metanode2.removeChild(internal[0]).unlink() |
|
|
|
|
|
if accessright=='free': |
|
nodenew3=dom.createElement('free') |
|
metanode2.appendChild(nodenew3) |
|
elif accessright=='mpiwg': |
|
nodenew3=dom.createElement('internal') |
|
nodenew4=dom.createElement('institution') |
|
metanodetext=dom.createTextNode('mpiwg') |
|
nodenew4.appendChild(metanodetext) |
|
nodenew3.appendChild(nodenew4) |
|
metanode2.appendChild(nodenew3) |
|
|
|
return dom.toxml().encode('utf-8') |
|
|
def setStartPageForm(self): |
def setStartPageForm(self): |
"""Form for changing the startpage""" |
"""Form for changing the startpage""" |
|
|
Line 493 class ECHO_resource(Folder,Persistent):
|
Line 431 class ECHO_resource(Folder,Persistent):
|
return pt() |
return pt() |
|
|
|
|
|
def createImageUrl(self,pn=1): |
|
"""create ImageUrl""" |
|
|
|
|
|
resourcepath=readFieldFromXML(self.metalink,'resource','archive-path') |
|
|
|
digiliburlprefix=readFieldFromXML(self.metalink,'texttool','digiliburlprefix') |
|
images=readFieldFromXML(self.metalink,'texttool','image') |
|
|
|
|
|
if (not resourcepath) or (not digiliburlprefix) or (not images): |
|
zLOG.LOG("ECHO (createImageUrl)",zLOG.ERROR,"Cannot create ImageUrl for %s"%self.absolute_url()) |
|
return None |
|
resourcepath=resourcepath.replace('/mpiwg/online','') |
|
if not digiliburlprefix: digiliburlprefix="http://echo.mpiwg-berlin.mpg.de/zogilib?" |
|
|
|
if (not images) or (not resourcepath): return None |
|
|
|
return "%sfn=%s&pn=%i"%(digiliburlprefix,resourcepath+"/"+images,pn) |
|
|
|
def copyTitleToInfoXML(self,RESPONSE=None): |
|
"""copy title from the resource""" |
|
presentationXML=readFieldFromXML(self.metalink,'texttool','presentation') |
|
resourcepath=readFieldFromXML(self.metalink,'resource','archive-path') |
|
if (not presentationXML) or (not resourcepath): |
|
if RESPONSE: |
|
RESPONSE.write("Error: %s\n"%self.getId()) |
|
else: |
|
return None,self.absolute_url() |
|
|
|
try: |
|
fh=file(os.path.join(resourcepath,presentationXML),'w') |
|
fh.write("""<info> |
|
<author></author> |
|
<title>%s</title> |
|
<date></date> |
|
<display>yes</display> |
|
</info>"""%self.title) |
|
fh.close() |
|
return 1,self.getId() |
|
except: |
|
if RESPONSE: |
|
RESPONSE.write("Error: %s\n"%self.getId()) |
|
else: |
|
return None,self.absolute_url() |
|
|
|
|
def setStartPage(self,startpage=None,RESPONSE=None): |
def setStartPage(self,startpage=None,RESPONSE=None): |
"""set start page, if no startpage defined use the generic one of the resource""" |
"""set start page, if no startpage defined use the generic one of the resource""" |
|
|
if (not (type(startpage)==StringType)) and ("__generic" in startpage): # checke ob generic in der liste |
if (not (type(startpage)==StringType)): |
|
if ("__generic" in startpage): # checke ob generic in der liste |
startpage=self.absolute_url()+"/startpage_html" |
startpage=self.absolute_url()+"/startpage_html" |
|
elif ("__firstPage" in startpage): # checke ob generic in der liste |
|
startpage=self.createImageUrl() |
|
|
if (not startpage) or (startpage=="__generic"): |
if (not startpage): |
startpage=self.absolute_url()+"/startpage_html" |
startpage=self.absolute_url()+"/startpage_html" |
|
elif (startpage=="__generic"): |
|
startpage=self.absolute_url()+"/startpage_html" |
|
elif (startpage=="__firstPage"): |
|
startpage=self.createImageUrl() |
|
|
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)) |
|
|
urllib.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() |
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() |
|
|
|
|
path=self.metalink |
path=self.metalink |
Line 515 class ECHO_resource(Folder,Persistent):
|
Line 507 class ECHO_resource(Folder,Persistent):
|
|
|
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.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://content.mpiwg-berlin.mpg.de','',path) # falls content als server |
|
path=re.sub('http://foxridge.rz-berlin.mpg.de','',path) # falls foxridge als server |
|
path=re.sub('http://vision.mpiwg-berlin.mpg.de','',path) # falls vision als server |
|
path=re.sub('http://xserve02.mpiwg-berlin.mpg.de:18880','',path) # falls vision als server |
|
path=re.sub('http://echo.mpiwg-berlin.mpg.de','',path) # falls echo |
path=re.sub('/index.meta','',path) |
path=re.sub('/index.meta','',path) |
|
|
|
|
urllib.urlopen("http://nausikaa2.rz-berlin.mpg.de:86/cgi-bin/toc/admin/reg.cgi?path=%s"%path).readlines() |
ECHO_helpers.urlopen("http://nausikaa2.rz-berlin.mpg.de:86/cgi-bin/toc/admin/reg.cgi?path=%s"%path).readlines() |
|
|
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
Line 530 class ECHO_resource(Folder,Persistent):
|
Line 527 class ECHO_resource(Folder,Persistent):
|
return pt() |
return pt() |
|
|
|
|
|
|
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 548 class ECHO_resource(Folder,Persistent):
|
Line 546 class ECHO_resource(Folder,Persistent):
|
return default |
return default |
|
|
|
|
def changeViewerTemplateSet(self,project,xslt,thumbtemplate,topbar,digiLibTemplate,RESPONSE=None): |
def changeViewerTemplateSet(self,project,xslt,thumbtemplate,topbar,digiLibTemplate,digiliburlprefix,RESPONSE=None): |
"""changeit""" |
"""changeit""" |
|
|
paramList=['project','startpage','xslt','thumbtemplate','topbar','digiLibTemplate'] |
paramList=['project','startpage','xslt','thumbtemplate','topbar','digiLibTemplate','digiliburlprefix'] |
|
|
|
|
writeMetadata(self.metalink,self.metaDataHash,project,None,xslt,thumbtemplate,topbar,digiLibTemplate) |
#writeMetadata(self.metalink,self.metaDataHash,project,None,xslt,thumbtemplate,topbar,digiLibTemplate) |
|
|
params="project=%s&xslt=%s&thumbtemplate=%s&topbar=%s&digiLibTemplate=%s"%(project,xslt,thumbtemplate,topbar,digiLibTemplate) |
params="project=%s&xslt=%s&thumbtemplate=%s&topbar=%s&digiLibTemplate=%s&digiliburlprefix=%s"%(project,xslt,thumbtemplate,topbar,digiLibTemplate,digiliburlprefix) |
|
|
|
|
urllib.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() |
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() |
|
|
|
#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 575 class ECHO_resource(Folder,Persistent):
|
Line 574 class ECHO_resource(Folder,Persistent):
|
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.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 |
|
|
|
return ECHO_helpers.urlopen("http://nausikaa2.rz-berlin.mpg.de:86/cgi-bin/toc/admin/reg.cgi?path=%s"%path).readlines() |
|
|
return urllib.urlopen("http://nausikaa2.rz-berlin.mpg.de:86/cgi-bin/toc/admin/reg.cgi?path=%s"%path).readlines() |
|
|
|
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
|
|
def getTitle(self): |
|
"""title""" |
|
return self.title.encode('utf-8') |
|
|
|
def getLabel(self): |
|
"""title""" |
|
return self.label.encode('utf-8') |
|
|
|
def content_html(self): |
def content_html(self): |
"""template fuer content""" |
"""template fuer content""" |
return content_html(self,'resource') |
return ECHO_basis.content_html(self,'resource') |
|
|
def getViewClassification(self): |
def getViewClassification(self): |
if hasattr(self,'viewClassification'): |
if hasattr(self,'viewClassification'): |
Line 602 class ECHO_resource(Folder,Persistent):
|
Line 602 class ECHO_resource(Folder,Persistent):
|
|
|
def getFullTextXML(self,noredirect=None): |
def getFullTextXML(self,noredirect=None): |
"""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: |
fh=urllib.urlopen(self.metalink) |
#zLOG.LOG("ECHO Fulltext",zLOG.INFO,"open %s"%self.metalink) |
|
fh=ECHO_helpers.urlopen(self.metalink) |
|
#zLOG.LOG("ECHO Fulltext",zLOG.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) |
self.REQUEST.RESPONSE.setHeader('Content-Type','text/xml') |
|
|
#zLOG.LOG("ECHO Fulltext",zLOG.INFO,"found %s"%texturl) |
|
fh.close() |
|
#zLOG.LOG("ECHO Fulltext",zLOG.INFO,"closed fh") |
|
#keine url |
|
if not (texturl.split(":")[0] in ['http','ftp','file']): |
|
if not noredirect: |
|
return file(texturl).read() |
|
else: |
|
return texturl |
|
|
if not noredirect: |
if not noredirect: |
|
self.REQUEST.RESPONSE.setHeader('Content-Type','text/xml') |
|
zLOG.LOG("ECHO Fulltext",zLOG.INFO,"redirect to:%s"%texturl) |
self.REQUEST.RESPONSE.redirect(texturl) |
self.REQUEST.RESPONSE.redirect(texturl) |
else: |
else: |
return texturl |
return texturl |
Line 621 class ECHO_resource(Folder,Persistent):
|
Line 636 class ECHO_resource(Folder,Persistent):
|
else: |
else: |
return "<error>no fulltext available</error>" |
return "<error>no fulltext available</error>" |
|
|
|
|
|
def getImageView(self,noredirect=None): |
|
"""getImages; give Imageviewr and <error></error> if somthing goes wrong.""" |
|
try: |
|
fh=ECHO_helpers.urlopen(self.metalink) |
|
dom=xml.dom.minidom.parse(fh) |
|
texttools=dom.getElementsByTagName('texttool') |
|
text=texttools[0].getElementsByTagName('image') |
|
imagetemp=getText(text[0].childNodes) |
|
|
|
text=dom.getElementsByTagName('archive-path') |
|
archivepath=getText(text[0].childNodes) |
|
archivepath=re.sub('/mpiwg/online/','',archivepath) |
|
imageurl="http://echo.mpiwg-berlin.mpg.de/zogilib?fn="+archivepath+"/"+imagetemp |
|
fh.close() |
|
|
|
if not noredirect: |
|
self.REQUEST.RESPONSE.setHeader('Content-Type','text/xml') |
|
self.REQUEST.RESPONSE.redirect(imageurl) |
|
else: |
|
return imageurl |
|
except: |
|
|
|
if not noredirect: |
|
self.REQUEST.RESPONSE.setHeader('Content-Type','text/xml') |
|
self.REQUEST.RESPONSE.write("<error>no fulltext available</error>") |
|
else: |
|
return "<error>no images available</error>" |
|
|
|
|
def getCopyrightsHTML(self): |
def getCopyrightsHTML(self): |
"""gib (link auf copyright link, mediatyp, institution, copyrightType, label von copyrightType) aus""" |
"""gib (link auf copyright link, mediatyp, institution, copyrightType, label von copyrightType) aus""" |
|
|
Line 631 class ECHO_resource(Folder,Persistent):
|
Line 676 class ECHO_resource(Folder,Persistent):
|
return "ERROR" |
return "ERROR" |
ret=[] |
ret=[] |
|
|
for copyright in obj.getCopyrights(): |
for copyright in obj.getCopyrights(): #copyright - media / partner / copyrightID |
|
|
link="copyrightTypes/"+copyright[2]+'/copyright.html' |
|
|
|
try: |
try: |
|
if hasattr(self.copyrightTypes,copyright[2]): |
copyrightTypeObj=getattr(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 |
label=copyrightTypeObj.label |
url=copyrightTypeObj.url |
url=getattr(copyrightTypeObj, 'url', '') |
|
|
if url!='': |
if url!='': |
ret.append((url,copyright[0],copyright[1],copyright[2],label)) |
ret.append((url,copyright[0],copyright[1],copyright[2],label)) |
Line 652 class ECHO_resource(Folder,Persistent):
|
Line 702 class ECHO_resource(Folder,Persistent):
|
|
|
return ret |
return ret |
|
|
|
def getInstitutionsHTML(self): |
|
"""gibt Liste der fšrdernden Institutionen aus""" |
|
|
|
if hasattr(self,'support'): |
|
obj=self.support |
|
ret=obj.getSupporter() |
|
return ret |
|
else: |
|
return '' |
|
|
|
|
def getCredits(self): |
def getCredits(self): |
"""Ausgabe der credits""" |
"""Ausgabe der credits""" |
if self.credits: |
if self.credits: |
Line 686 class ECHO_resource(Folder,Persistent):
|
Line 747 class ECHO_resource(Folder,Persistent):
|
|
|
|
|
def getCoords(self): |
def getCoords(self): |
"""gibt coordinaten als String zurück und löscht zugleich einträge die keine Koordinaten sind, letzteres zur korrektur der Eingabe der alten version""" |
"""gibt coordinaten als String zurück und löscht zugleich einträge die keine Koordinaten sind, letzteres zur korrektur der Eingabe der alten version""" |
retList=[] |
retList=[] |
if hasattr(self,'coords'): |
if hasattr(self,'coords'): |
for x in self.coords: |
for x in self.coords: |
Line 753 class ECHO_resource(Folder,Persistent):
|
Line 814 class ECHO_resource(Folder,Persistent):
|
self.contentType=self.bib_type |
self.contentType=self.bib_type |
for data in self.metadata: |
for data in self.metadata: |
data_neu=re.sub('-','_',data) |
data_neu=re.sub('-','_',data) |
self.metaDataHash[data_neu]=getattr(self,data)[0:] |
self.meta |
|
DataHash[data_neu]=getattr(self,data)[0:] |
|
|
|
|
pt=PageTemplateFile('Products/ECHO_content/zpt/ChangeECHO_resource_metadata.zpt').__of__(self) |
pt=PageTemplateFile('Products/ECHO_content/zpt/ChangeECHO_resource_metadata.zpt').__of__(self) |
Line 763 class ECHO_resource(Folder,Persistent):
|
Line 825 class ECHO_resource(Folder,Persistent):
|
|
|
|
|
def changeECHO_resource_main(self,metalink,link,title,label,description,contentType,renderingType,weight,resourceID,RESPONSE=None): |
def changeECHO_resource_main(self,metalink,link,title,label,description,contentType,renderingType,weight,resourceID,RESPONSE=None): |
"""Änderung der Properties""" |
"""Änderung der Properties""" |
self.resourceID=resourceID |
self.resourceID=resourceID |
self.title=title |
self.title=title |
self.label=label |
self.label=label |
Line 781 class ECHO_resource(Folder,Persistent):
|
Line 843 class ECHO_resource(Folder,Persistent):
|
|
|
|
|
def changeECHO_resource_coords(self,coords,viewClassification,RESPONSE=None): |
def changeECHO_resource_coords(self,coords,viewClassification,RESPONSE=None): |
"""Änderung der Properties - coords""" |
"""Änderung der Properties - coords""" |
|
|
if type(coords)==StringType: |
if type(coords)==StringType: |
coords=[coords] |
coords=[coords] |
Line 798 class ECHO_resource(Folder,Persistent):
|
Line 860 class ECHO_resource(Folder,Persistent):
|
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
def changeECHO_resource_credits(self,credits,responsible,copyrightType,RESPONSE=None): |
def changeECHO_resource_credits(self,credits,responsible,copyrightType,RESPONSE=None): |
"""Änderung der Properties""" |
"""Änderung der Properties""" |
self.credits=credits |
self.credits=credits |
self.responsible=responsible |
self.responsible=responsible |
self.copyrightType=copyrightType |
self.copyrightType=copyrightType |
Line 829 class ECHO_resource(Folder,Persistent):
|
Line 891 class ECHO_resource(Folder,Persistent):
|
except: |
except: |
"""nothing""" |
"""nothing""" |
|
|
urllib.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() |
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 RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
|
|
def getMDValue(self,fieldName): |
def getMDValue(self,fieldName,empty=None): |
|
if empty: |
return self.metaDataHash.get(fieldName,'!!NOT USED HERE in Type: %s'%self.contentType) |
return self.metaDataHash.get(fieldName,'!!NOT USED HERE in Type: %s'%self.contentType) |
|
|
def newMetaXML(self,project=None,startpage=None,xslt=None,thumbtemplate=None,topbar=None,digiLibTemplate=None): |
else: |
|
return self.metaDataHash.get(fieldName,empty) |
|
|
|
def newMetaXML(self,project=None,startpage=None,xslt=None,thumbtemplate=None,topbar=None,digiLibTemplate=None,digiliburlprefix=None): |
"""new index.meta""" |
"""new index.meta""" |
self.REQUEST.RESPONSE.setHeader('Content-Type','text/xml') |
self.REQUEST.RESPONSE.setHeader('Content-Type','text/xml') |
|
|
if not hasattr(self,'metaDataHash'): |
if not hasattr(self,'metaDataHash'): |
|
|
self.copyIndex_meta2echo_resource() |
self.copyIndex_meta2echo_resource() |
try: |
try: |
return writeMetadata(self.metalink,self.OSAS_meta,project,startpage,xslt,thumbtemplate,topbar,digiLibTemplate) |
return writeMetadata(self.metalink,self.OSAS_meta,project,startpage,xslt,thumbtemplate,topbar,digiLibTemplate,digiliburlprefix=digiliburlprefix) |
except: |
except: |
return writeMetadata(self.metalink,self.metaDataHash,project,startpage,xslt,thumbtemplate,topbar,digiLibTemplate) |
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): |
|
"""schreibe md""" |
|
|
|
try: |
|
|
|
return writeMetadata(self.metalink,self.metaDataHash,project,startpage,xslt,thumbtemplate,topbar,digiLibTemplate,xmlfrag="yes") |
|
except: |
|
return "<error> no metadata stored</error>" |
|
|
def getMetaDataXML(self,project=None,startpage=None,xslt=None,thumbtemplate=None,topbar=None,digiLibTemplate=None): |
def getMetaDataXML(self,project=None,startpage=None,xslt=None,thumbtemplate=None,topbar=None,digiLibTemplate=None): |
"""prints out metadata as stored in the echo environment, format is the index.meta format""" |
"""prints out metadata as stored in the echo environment, format is the index.meta format""" |
Line 856 class ECHO_resource(Folder,Persistent):
|
Line 932 class ECHO_resource(Folder,Persistent):
|
return writeMetadata(self.metalink,self.metaDataHash) |
return writeMetadata(self.metalink,self.metaDataHash) |
|
|
def changeECHO_resource(self,metalink,link,title,label,description,contentType,responsible,weight,viewClassification="",coords=None,credits=None,RESPONSE=None): |
def changeECHO_resource(self,metalink,link,title,label,description,contentType,responsible,weight,viewClassification="",coords=None,credits=None,RESPONSE=None): |
"""Änderung der Properties""" |
"""Änderung der Properties""" |
|
|
try: |
try: |
coordsnew=[ string.split(x,",") for x in coords] |
coordsnew=[ string.split(x,",") for x in coords] |
Line 879 class ECHO_resource(Folder,Persistent):
|
Line 955 class ECHO_resource(Folder,Persistent):
|
{'label':'Change Coords','action':'ECHO_resource_config_coords'}, |
{'label':'Change Coords','action':'ECHO_resource_config_coords'}, |
{'label':'Add coords','action':'ECHO_graphicEntry'}, |
{'label':'Add coords','action':'ECHO_graphicEntry'}, |
{'label':'Sync Metadata','action':'ECHO_getResourceMD'}, |
{'label':'Sync Metadata','action':'ECHO_getResourceMD'}, |
{'label':'Change TemplateSets','action':'changeViewerTemplateSetForm'}, |
{'label':'Change TemplateSets and Image Viewer','action':'changeViewerTemplateSetForm'}, |
{'label':'set/change startpage','action':'setStartPageForm'}, |
{'label':'set/change startpage','action':'setStartPageForm'}, |
|
{'label':'Copy MD for indexing and search','action':'copySearchFields'}, |
) |
) |
|
|
def getOverview(self): |
def getOverview(self): |
Line 969 class ECHO_resource(Folder,Persistent):
|
Line 1046 class ECHO_resource(Folder,Persistent):
|
self.metaDataHash[field]=value[0:] |
self.metaDataHash[field]=value[0:] |
|
|
|
|
|
def copySearchFields(self): |
|
"""copys metadatafields to the object""" |
|
fields=['author','title','year'] |
|
for field in fields: |
|
setattr(self,'MD_'+field,self.getFieldValue(field)) |
|
|
|
|
def findLabelsFromMapping(self,referenceType): |
def findLabelsFromMapping(self,referenceType): |
"""gib hash mit label -> generic zurueck""" |
"""gib hash mit label -> generic zurueck""" |
Line 1023 class ECHO_resource(Folder,Persistent):
|
Line 1106 class ECHO_resource(Folder,Persistent):
|
bibdata={} |
bibdata={} |
retdata={} |
retdata={} |
fieldlist=self.standardMD.fieldList |
fieldlist=self.standardMD.fieldList |
|
fields=[] |
for referenceTypeF in temp: |
for referenceTypeF in temp: |
|
#print referenceType |
|
|
if referenceTypeF[1].title.lower() == referenceType.lower(): |
if referenceTypeF[1].title.lower() == referenceType.lower(): |
try: |
try: |
Line 1046 class ECHO_resource(Folder,Persistent):
|
Line 1130 class ECHO_resource(Folder,Persistent):
|
|
|
(metadict, error)=readMetadata(self.metalink) |
(metadict, error)=readMetadata(self.metalink) |
|
|
self.contentType=metadict['bib_type'][0:] |
|
|
|
self.metaDataHash={} |
self.metaDataHash={} |
if not error=="": #Fehler beim Auslesen des Metafiles |
if not error=="": #Fehler beim Auslesen des Metafiles |
return "ERROR:",error |
|
|
return "ERROR:",error,self.absolute_url() |
|
|
|
self.contentType=metadict['bib_type'][0:] |
fields=self.findTagsFromMapping(self.contentType) |
fields=self.findTagsFromMapping(self.contentType) |
|
|
#fields=self.findLabelsFromMapping(self.contentType) |
#fields=self.findLabelsFromMapping(self.contentType) |
Line 1065 class ECHO_resource(Folder,Persistent):
|
Line 1152 class ECHO_resource(Folder,Persistent):
|
if RESPONSE: |
if RESPONSE: |
return RESPONSE.redirect('manage_main') |
return RESPONSE.redirect('manage_main') |
|
|
def ECHO_getResourceMD(self,template="yes"): |
def ECHO_getResourceMD(self,template="yes",back=None): |
"""Einlesen der Metadaten und Anlegen dieser Metadaten als Informationen zur Resource""" |
"""Einlesen der Metadaten und Anlegen dieser Metadaten als Informationen zur Resource""" |
(metadict, error)=readMetadata(self.metalink) |
(metadict, error)=readMetadata(self.metalink) |
|
|
|
if back: |
|
self.REQUEST.SESSION['back']=back |
|
|
if not error=="": #Fehler beim Auslesen des Metafiles |
if not error=="": #Fehler beim Auslesen des Metafiles |
return "ERROR:",error |
return "ERROR:",error |
Line 1101 class ECHO_resource(Folder,Persistent):
|
Line 1189 class ECHO_resource(Folder,Persistent):
|
"""Ausgabe der MD""" |
"""Ausgabe der MD""" |
return getattr(self,item) |
return getattr(self,item) |
|
|
|
def checkRDF(self,path): |
|
"""check if pdf behind path""" |
|
try: |
|
for fileName in os.listdir(path): |
|
if os.path.splitext(fileName)[1]==".pdf": |
|
return os.path.join(path,fileName) |
|
return None |
|
except: |
|
return None |
|
|
|
|
def index_html(self): |
def index_html(self): |
"""standard page""" |
"""standard page""" |
|
pdf=self.checkRDF(self.link) |
|
if pdf: |
|
fh=file(pdf,'r').read() |
|
self.REQUEST.RESPONSE.setHeader('Content-Type','x-Application/pdf') |
|
self.REQUEST.RESPONSE.write(fh) |
|
self.REQUEST.RESPONSE.close() |
|
return |
return self.REQUEST.RESPONSE.redirect(self.link) |
return self.REQUEST.RESPONSE.redirect(self.link) |
|
|
def startpage_html(self): |
def startpage_html(self): |
Line 1116 class ECHO_resource(Folder,Persistent):
|
Line 1221 class ECHO_resource(Folder,Persistent):
|
if sp: |
if sp: |
return sp[1]() |
return sp[1]() |
|
|
#prüfen ob irgendwo ein template |
#prüfen ob irgendwo ein template |
if hasattr(self,'startpage_index_template'): |
if hasattr(self,'startpage_index_template'): |
return self.startpage_index_template() |
return self.startpage_index_template() |
|
|
Line 1135 class ECHO_resource(Folder,Persistent):
|
Line 1240 class ECHO_resource(Folder,Persistent):
|
|
|
|
|
security.declarePublic('generate_label') # has to be change, presentlyset because of OSAS koordination |
security.declarePublic('generate_label') # has to be change, presentlyset because of OSAS koordination |
|
|
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_"+self.contentType.lower()) |
Line 1143 class ECHO_resource(Folder,Persistent):
|
Line 1249 class ECHO_resource(Folder,Persistent):
|
return pt() |
return pt() |
|
|
security.declarePublic('generate_title') # has to be change, presentlyset because of OSAS koordination |
security.declarePublic('generate_title') # has to be change, presentlyset because of OSAS koordination |
|
|
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_"+self.contentType.lower()) |
Line 1171 def manage_addECHO_resource(self,id,titl
|
Line 1278 def manage_addECHO_resource(self,id,titl
|
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
|
|
class ECHO_externalLink(Folder): |
class ECHO_externalLink(Folder,ECHO_basis): |
"""Link zu einer externen Ressource""" |
"""Link zu einer externen Ressource""" |
security=ClassSecurityInfo() |
security=ClassSecurityInfo() |
meta_type='ECHO_externalLink' |
meta_type='ECHO_externalLink' |
|
|
def getTitle(self): |
|
"""title""" |
|
return self.title.encode('utf-8') |
|
|
|
def getLabel(self): |
|
"""title""" |
|
return self.label.encode('utf-8') |
|
|
|
def content_html(self): |
def content_html(self): |
"""template fuer content""" |
"""template fuer content""" |
return content_html(self,'externalLink') |
return ECHO_basis.content_html(self,'externalLink') |
|
|
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): |
|
|
Line 1220 class ECHO_externalLink(Folder):
|
Line 1320 class ECHO_externalLink(Folder):
|
|
|
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): |
|
|
"""Änderung der Properties""" |
"""Änderung der Properties""" |
try: |
try: |
coordsnew=[ string.split(x,",") for x in coords] |
coordsnew=[ string.split(x,",") for x in coords] |
except: |
except: |
Line 1270 class ECHO_link(ECHO_externalLink):
|
Line 1370 class ECHO_link(ECHO_externalLink):
|
def content_html(self): |
def content_html(self): |
"""template fuer link""" |
"""template fuer link""" |
if hasattr(self,"link_template"): |
if hasattr(self,"link_template"): |
return content_html(self,'link') |
return ECHO_basis.content_html(self,'link') |
else: |
else: |
return content_html(self,'collection') |
return ECHO_basis.content_html(self,'collection') |
|
|
def manage_addECHO_linkForm(self): |
def manage_addECHO_linkForm(self): |
"""Form for external Links""" |
"""Form for external Links""" |
Line 1291 def manage_addECHO_link(self,id,title,la
|
Line 1391 def manage_addECHO_link(self,id,title,la
|
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
|
|
class ECHO_collection(Folder, Persistent, Implicit): |
class ECHO_collection(Folder, Persistent, Implicit, Cacheable,ECHO_basis): |
"""ECHO Collection""" |
"""ECHO Collection""" |
|
|
security=ClassSecurityInfo() |
security=ClassSecurityInfo() |
Line 1299 class ECHO_collection(Folder, Persistent
|
Line 1399 class ECHO_collection(Folder, Persistent
|
viewClassificationList=viewClassificationListMaster |
viewClassificationList=viewClassificationListMaster |
displayTypes=displayTypes |
displayTypes=displayTypes |
|
|
|
path="/mpiwg/online/permanent/shipbuilding" |
|
|
|
def getRDF(self,urn=None): |
|
"""rdf of the collection""" |
|
|
|
contents=self.ZopeFind(self,obj_metatypes=['ECHO_group','ECHO_resource','ECHO_collection']) |
|
|
|
ret=getRDFDescription(self,self.absolute_url(),urn=urn) |
|
|
|
if not urn: |
|
urn=self.absolute_url() |
|
|
|
li="""<RDF:li RDF:resource="%s" />\n""" |
|
|
|
|
|
for content in contents: |
|
ret+=content[1].getRDF()+"\n" |
|
|
|
ret+="""<RDF:Seq RDF:about="%s">\n"""%urn |
|
for content in contents: |
|
nurn=content[1].absolute_url() |
|
ret+=li%nurn |
|
return ret+"</RDF:Seq>" |
|
|
|
|
|
|
|
def changeLabels(self): |
|
"""change form""" |
|
pt=PageTemplateFile('Products/ECHO_content/zpt/changeLabelsForm').__of__(self) |
|
pt.content_type="text/html" |
|
return pt() |
|
|
|
def changeTitles(self): |
|
"""change form""" |
|
pt=PageTemplateFile('Products/ECHO_content/zpt/changeTitleForm').__of__(self) |
|
pt.content_type="text/html" |
|
return pt() |
|
|
|
def changeWeights(self): |
|
"""change form""" |
|
pt=PageTemplateFile('Products/ECHO_content/zpt/changeWeightForm').__of__(self) |
|
pt.content_type="text/html" |
|
return pt() |
|
|
|
def changeMetaDataLinks(self): |
|
"""change form""" |
|
pt=PageTemplateFile('Products/ECHO_content/zpt/changeMetaDataLinkForm').__of__(self) |
|
pt.content_type="text/html" |
|
return pt() |
|
def changeAccessRightsCollection(self): |
|
"""change""" |
|
ret="" |
|
argv=self.REQUEST.form |
|
|
|
resources=self.ZopeFind(self,obj_metatypes=['ECHO_resource']) |
|
for resource in resources: |
|
|
|
try: |
|
ret+=resource[1].getId()+" "+argv[resource[1].getId()]+"</br>" |
|
resource[1].changeAccessRightMD(argv[resource[1].getId()]) |
|
except: |
|
"""not""" |
|
return ret |
|
|
|
def changeMetaDataLinkInCollection(self): |
|
"""change all lables of a collection""" |
|
ret="" |
|
argv=self.REQUEST.form |
|
|
|
resources=self.ZopeFind(self,obj_metatypes=['ECHO_resource']) |
|
for resource in resources: |
|
|
|
try: |
|
ret+=resource[1].getId()+" "+argv[resource[1].getId()]+"</br>" |
|
resource[1].metalink=argv[resource[1].getId()][0:] |
|
except: |
|
"""not""" |
|
return ret |
|
|
|
def changeMetaDataLinkInCollection(self): |
|
"""change all lables of a collection""" |
|
ret="" |
|
argv=self.REQUEST.form |
|
|
|
resources=self.ZopeFind(self,obj_metatypes=['ECHO_resource']) |
|
for resource in resources: |
|
|
|
try: |
|
ret+=resource[1].getId()+" "+argv[resource[1].getId()]+"</br>" |
|
resource[1].metalink=argv[resource[1].getId()][0:] |
|
except: |
|
"""not""" |
|
return ret |
|
|
|
def changeWeightsInCollection(self): |
|
"""change all lables of a collection""" |
|
ret="" |
|
argv=self.REQUEST.form |
|
|
|
resources=self.ZopeFind(self,obj_metatypes=['ECHO_pageTemplate','ECHO_resource','ECHO_collection','ECHO_link','ECHO_externalLink']) |
|
for resource in resources: |
|
|
|
try: |
|
ret+=resource[1].getId()+" "+argv[resource[1].getId()]+"</br>" |
|
resource[1].weight=argv[resource[1].getId()][0:] |
|
except: |
|
"""not""" |
|
return ret |
|
|
|
def changeTitlesInCollection(self): |
|
"""change all lables of a collection""" |
|
ret="" |
|
argv=self.REQUEST.form |
|
|
|
resources=self.ZopeFind(self,obj_metatypes=['ECHO_resource']) |
|
for resource in resources: |
|
|
|
try: |
|
ret+=resource[1].getId()+" "+argv[resource[1].getId()]+"</br>" |
|
resource[1].title=argv[resource[1].getId()][0:] |
|
except: |
|
"""not""" |
|
return ret |
|
|
|
def updateCollection(self,RESPONSE=None): |
|
"""liest verzeichnisse aus dem pfad und legt sie dann als objekte in den ordner""" |
|
files=os.listdir(self.path) |
|
ret="" |
|
for fileName in files: |
|
|
|
if fileName: |
|
|
|
tempPath=re.sub("/mpiwg/online","",self.path) |
|
link="http://echo.mpiwg-berlin.mpg.de/zogilib_book?fn="+tempPath+"/"+fileName+"/pageimg" |
|
|
|
metalink=self.path+"/"+fileName+"/index.meta" |
|
try: |
|
|
|
#link="http://nausikaa2.mpiwg-berlin.mpg.de/cgi-bin/toc/toc.x.cgi?dir="+fileName+"&step=thumb" |
|
|
|
newObj=ECHO_resource(fileName,link,metalink,fileName,fileName,fileName,'generated','book','','','','','','') |
|
self._setObject(fileName,newObj) |
|
|
|
genObj=getattr(self,fileName) |
|
#genObj.createIndexFile() |
|
ret+="OK:"+fileName+"<br/>" |
|
except: |
|
print "ERROR" |
|
ret+="ERROR:"+fileName+"<br/>" |
|
|
|
return ret |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
def updateCollectionMD(self,RESPONSE=None): |
|
"""updateMD""" |
|
files=os.listdir(self.path) |
|
for fileName in files: |
|
if fileName: |
|
genObj=getattr(self,fileName) |
|
genObj.copyIndex_meta2echo_resource() |
|
genObj.generate_title() |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
|
|
|
def changeViewerTemplateSetsForm(self): |
def changeViewerTemplateSetsForm(self): |
"""change the viewer template set""" |
"""change the viewer template set""" |
pt=PageTemplateFile('Products/ECHO_content/zpt/changeViewerTemplateSet').__of__(self) |
pt=PageTemplateFile('Products/ECHO_content/zpt/changeViewerTemplateSet').__of__(self) |
return pt() |
return pt() |
|
|
def getViewerTemplateSets(self,obj_ids=None): |
def getViewerTemplateSets(self,obj_ids=None,RESPONSE=None): |
"""Get the ViewerTemplateSet title for configuration""" |
"""Get the ViewerTemplateSet title for configuration""" |
ret=[] |
ret=[] |
|
|
Line 1327 class ECHO_collection(Folder, Persistent
|
Line 1595 class ECHO_collection(Folder, Persistent
|
|
|
|
|
def isSelectedViewerTemplateSet(self,obj,id): |
def isSelectedViewerTemplateSet(self,obj,id): |
"""is ausgewählt""" |
"""is ausgewählt""" |
|
|
if self.REQUEST['viewerTemplateSet']==id: |
if self.REQUEST['viewerTemplateSet']==id: |
return 1 |
return 1 |
else: |
else: |
return None |
return None |
|
|
def changeViewerTemplateSets(self,project,xslt,thumbtemplate,topbar,digiLibTemplate,RESPONSE=None): |
def changeViewerTemplateSets(self,project,xslt,thumbtemplate,topbar,digiLibTemplate,digiliburlprefix,RESPONSE=None): |
"""change the templates""" |
"""change the templates""" |
|
|
|
resources=self.ZopeFind(self,obj_metatypes=['ECHO_resource'],search_sub=1) |
|
|
|
for resource in resources: |
|
|
|
resource[1].changeViewerTemplateSet(project,xslt,thumbtemplate,topbar,digiLibTemplate,digiliburlprefix) |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
|
|
def setStartpageFolderForm(self): |
|
"""Form for changing the startpage""" |
|
|
|
|
|
pt=PageTemplateFile('Products/ECHO_content/zpt/ChangeECHO_resourceStartPageFolder.zpt').__of__(self) |
|
pt.content_type="text/html" |
|
return pt() |
|
|
|
def setStartpageFolder(self,startpage=None,RESPONSE=None): |
|
"""change the templates""" |
|
|
|
resources=self.ZopeFind(self,obj_metatypes=['ECHO_resource'],search_sub=1) |
|
|
|
for resource in resources: |
|
|
|
resource[1].setStartPage(startpage) |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
def copyTitleToInfoXMLFolder(self,RESPONSE=None): |
|
"""copy title into the title field of info.xml |
|
author and date werden leer!!! |
|
""" |
|
|
|
|
|
resources=self.ZopeFind(self,obj_metatypes=['ECHO_resource'],search_sub=1) |
|
|
|
|
|
for resource in resources: |
|
ret,txt=resource[1].copyTitleToInfoXML() |
|
if (not ret) and RESPONSE: |
|
RESPONSE.write("error: %s\n"%txt) |
|
if ret and RESPONSE: |
|
RESPONSE.write("ok: %s\n"%txt) |
|
|
|
#zLOG.LOG("ECHO (copyTitleToInfoXMLFolder)",zLOG.INFO,txt) |
|
if RESPONSE is not None: |
|
RESPONSE.write("done!\n") |
|
RESPONSE.close() |
|
RESPONSE.redirect('manage_main') |
|
|
|
def copySearchFields(self,RESPONSE=None): |
|
"""copys import metadatafields to the object""" |
resources=self.ZopeFind(self,obj_metatypes=['ECHO_resource']) |
resources=self.ZopeFind(self,obj_metatypes=['ECHO_resource']) |
|
|
for resource in resources: |
for resource in resources: |
print resource[0] |
|
resource[1].changeViewerTemplateSet(project,xslt,thumbtemplate,topbar,digiLibTemplate) |
resource[1].copySearchFields() |
|
|
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
|
def reloadMetaDataFromStorageWarning(self,RESPONSE=None): |
|
"""warning""" |
|
pt=PageTemplateFile('Products/ECHO_content/zpt/reloadMetaDataFromStorageWarning.zpt').__of__(self) |
|
pt.content_type="text/html" |
|
return pt() |
|
|
|
def reloadMetaDataFromStorage(self,RESPONSE=None): |
|
"""copy metadata from the storage to ECHO""" |
|
|
|
return reloadMetaDataFromStorage(self,RESPONSE=None) |
|
|
|
|
def getPartnerCopyright(self,name,sonst="generic"): |
def getPartnerCopyright(self,name,sonst="generic"): |
"""gibt generisches copyright eines partners aus, sonst behalte jetzige einsteillung""" |
"""gibt generisches copyright eines partners aus, sonst behalte jetzige einsteillung""" |
Line 1381 class ECHO_collection(Folder, Persistent
|
Line 1714 class ECHO_collection(Folder, Persistent
|
else: |
else: |
return "" |
return "" |
|
|
def getTitle(self): |
|
"""title""" |
|
return self.title.encode('utf-8') |
|
|
|
def getLabel(self): |
|
"""title""" |
|
return self.label.encode('utf-8') |
|
|
|
|
|
|
|
def createRessourcesFromXMLForm(self): |
def createRessourcesFromXMLForm(self): |
"""form""" |
"""form""" |
Line 1410 class ECHO_collection(Folder, Persistent
|
Line 1734 class ECHO_collection(Folder, Persistent
|
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'),"","","",link.encode('ascii'),"","") |
return ret |
return ret |
|
|
def getImageTag(self): |
def getImageTag(self): |
"""GetTag""" |
"""GetTag""" |
try: |
try: |
Line 1442 class ECHO_collection(Folder, Persistent
|
Line 1767 class ECHO_collection(Folder, Persistent
|
def getCollectionTreeXML(self): |
def getCollectionTreeXML(self): |
"""Tree as XML""" |
"""Tree as XML""" |
|
|
|
def addPassWd(str): |
|
"""adds a user/passwd to an url""" |
|
txt2=re.sub(r"(http://)(.*?)","\g<1>www:3333@\g<2>",str) |
|
return txt2 |
|
|
def getCollection(object,depth=0): |
def getCollection(object,depth=0): |
depth+=1 |
depth+=1 |
collections="" |
collections="" |
Line 1449 class ECHO_collection(Folder, Persistent
|
Line 1779 class ECHO_collection(Folder, Persistent
|
element=getattr(object,entry) |
element=getattr(object,entry) |
try: |
try: |
if element.meta_type in ["ECHO_collection","ECHO_group"]: |
if element.meta_type in ["ECHO_collection","ECHO_group"]: |
collections+="<element name=\""+quote(element.title)+"\" url=\""+element.absolute_url()+"\">" |
collections+="<element name=\""+quote(element.title)+"\" url=\""+addPassWd(element.absolute_url())+"\">" |
collections+=getCollection(element,depth)+"</element>\n" |
collections+=getCollection(element,depth)+"</element>\n" |
except: |
except: |
"""nothing""" |
"""nothing""" |
Line 1587 class ECHO_collection(Folder, Persistent
|
Line 1917 class ECHO_collection(Folder, Persistent
|
|
|
security.declarePublic('ECHO_rerenderLinksMD') |
security.declarePublic('ECHO_rerenderLinksMD') |
|
|
def ECHO_rerenderLinksMD(self,obj=None): |
|
"""Rerender all Links""" |
|
if not obj: |
|
obj = self |
|
|
|
entries=obj.ZopeFind(obj,obj_metatypes=['ECHO_resource','ECHO_collection']) |
def ECHO_rerenderLinksMDWarning(self): |
|
"""change form""" |
|
pt=PageTemplateFile('Products/ECHO_content/zpt/rerenderLinksWarning').__of__(self) |
|
pt.content_type="text/html" |
|
return pt() |
|
|
for entry in entries: |
|
if entry[1].meta_type == 'ECHO_resource': |
|
entry[1].ECHO_getResourceMD(template="no") |
|
entry[1].generate_title() |
|
entry[1].generate_label() |
|
|
|
else: |
|
self.ECHO_rerenderLinksMD(entry[1]) |
|
|
|
|
def ECHO_rerenderLinksMD(self,obj=None,types=['title','label']): |
|
"""Rerender all Links""" |
|
return ECHO_rerenderLinksMD(self,obj,types) |
|
|
|
|
return "Rerenderd all links to resources in: "+self.title |
|
|
|
security.declarePublic('ECHO_newViewerLink') |
security.declarePublic('ECHO_newViewerLink') |
|
|
|
|
Line 1641 class ECHO_collection(Folder, Persistent
|
Line 1965 class ECHO_collection(Folder, Persistent
|
self.bgcolour=bgcolour |
self.bgcolour=bgcolour |
|
|
|
|
manage_options = Folder.manage_options+( |
manage_options = Folder.manage_options+ Cacheable.manage_options+( |
{'label':'Main Config','action':'ECHO_collection_config'}, |
{'label':'Main Config','action':'ECHO_collection_config'}, |
{'label':'Rerender Links','action':'ECHO_rerenderLinksMD'}, |
{'label':'Change Labels','action':'changeLabels'}, |
|
{'label':'Change Titles','action':'changeTitles'}, |
|
{'label':'Change Weights','action':'changeWeights'}, |
|
{'label':'Rerender Labels and Titles','action':'ECHO_rerenderLinksMDWarning'}, |
{'label':'Graphics','action':'ECHO_graphicEntry'}, |
{'label':'Graphics','action':'ECHO_graphicEntry'}, |
{'label':'create resources from XML','action':'createRessourcesFromXMLForm'}, |
{'label':'create resources from XML','action':'createRessourcesFromXMLForm'}, |
{'label':'Change Viewer Templates','action':'changeViewerTemplateSetsForm'}, |
{'label':'Set Startpage','action':'setStartpageFolderForm'}, |
|
{'label':'Change Viewer Templates and Image Viewer','action':'changeViewerTemplateSetsForm'}, |
|
{'label':'Reload Metadata','action':'reloadMetaDataFromStorageWarning'}, |
|
{'label':'ImportCollection','action':'updateCollection'}, |
|
{'label':'Copy MD for indexing and search','action':'copySearchFields'}, |
) |
) |
|
|
def getOverview(self): |
def getOverview(self): |
Line 1705 class ECHO_collection(Folder, Persistent
|
Line 2036 class ECHO_collection(Folder, Persistent
|
else: |
else: |
return "#dddddd" |
return "#dddddd" |
|
|
def changeECHO_collection(self,title,label,description,contentType,responsible,weight,secondaryLink,secondaryLinkTitle,credits=None,sortfield="weight",coords=None,RESPONSE=None,imageTag="",bgcolour="",viewClassification=None,location=None): |
def changeECHO_collection(self,title,label,description,contentType,responsible,weight,secondaryLink,secondaryLinkTitle,credits=None,sortfield="weight",coords=None,RESPONSE=None,imageTag="",bgcolour="",viewClassification=None,location=None,isAlwaysClickable=None): |
"""Aenderung der Properties""" |
"""Aenderung der Properties""" |
|
|
self.secondaryLink=secondaryLink |
self.secondaryLink=secondaryLink |
Line 1714 class ECHO_collection(Folder, Persistent
|
Line 2045 class ECHO_collection(Folder, Persistent
|
self.bgcolour=bgcolour |
self.bgcolour=bgcolour |
self.viewClassification=viewClassification |
self.viewClassification=viewClassification |
self.location=location |
self.location=location |
|
self.isAlwaysClickable=isAlwaysClickable |
|
|
if coords: |
if coords: |
coordsnew=[ string.split(x,",") for x in coords] |
coordsnew=[ string.split(x,",") for x in coords] |
Line 1733 class ECHO_collection(Folder, Persistent
|
Line 2065 class ECHO_collection(Folder, Persistent
|
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
|
def setAlwaysClickable(self,flag="yes"): |
|
"""set clickable""" |
|
if flag=="yes": |
|
self.isAlwaysClickable="yes" |
|
else: |
|
self.isAlwaysClickable=None |
|
|
|
return flag |
|
|
def showOverview(self): |
def showOverview(self): |
"""overview""" |
"""overview""" |
Line 1745 class ECHO_collection(Folder, Persistent
|
Line 2085 class ECHO_collection(Folder, Persistent
|
|
|
def index_html(self): |
def index_html(self): |
"""standard page""" |
"""standard page""" |
|
if self.ZCacheable_isCachingEnabled(): |
|
|
|
result = self.ZCacheable_get() |
|
if result is not None: |
|
# Got a cached value. |
|
return result |
|
|
if 'index.html' in self.__dict__.keys(): |
if 'index.html' in self.__dict__.keys(): |
return getattr(self,'index.html')() |
ret=getattr(self,'index.html')() |
|
|
elif 'overview' in self.__dict__.keys(): |
elif 'overview' in self.__dict__.keys(): |
return self.showOverview() |
ret=self.showOverview() |
elif hasattr(self,'collection_index_template'): |
elif hasattr(self,'collection_index_template'): |
return self.collection_index_template() |
ret=self.collection_index_template() |
elif hasattr(self,'main_index_template'): |
elif hasattr(self,'main_index_template'): |
return self.main_index_template() |
ret=self.main_index_template() |
|
else: |
pt=PageTemplateFile('Products/ECHO_content/zpt/ECHO_main_index_template_standard.zpt').__of__(self) |
pt=PageTemplateFile('Products/ECHO_content/zpt/ECHO_main_index_template_standard.zpt').__of__(self) |
pt.content_type="text/html" |
pt.content_type="text/html" |
return pt() |
ret=pt.render() |
|
|
def content_html(self): |
self.ZCacheable_set(ret) |
|
return ret |
|
|
|
def content_html(self,**argv): |
"""template fuer content""" |
"""template fuer content""" |
return content_html(self,'collection') |
#print "NN",argv |
|
return ECHO_basis.content_html(self,'collection') |
|
|
def getCredits(self): |
def getCredits(self): |
"""Ausgabe der credits""" |
"""Ausgabe der credits""" |
Line 1850 class ECHO_group(ECHO_collection):
|
Line 2200 class ECHO_group(ECHO_collection):
|
|
|
manage_options = Folder.manage_options+( |
manage_options = Folder.manage_options+( |
{'label':'Main Config','action':'ECHO_group_config'}, |
{'label':'Main Config','action':'ECHO_group_config'}, |
{'label':'Rerender Links','action':'ECHO_rerenderLinksMD'}, |
{'label':'Rerender Links','action':'ECHO_rerenderLinksMDWarning'}, |
{'label':'Graphics','action':'ECHO_graphicEntry'}, |
{'label':'Graphics','action':'ECHO_graphicEntry'}, |
) |
) |
|
|
security.declareProtected('View','index_html') |
security.declareProtected('View','index_html') |
|
|
|
|
|
def getRDF(self,urn=None): |
|
"""rdf of the collection""" |
|
contents=self.ZopeFind(self,obj_metatypes=['ECHO_group','ECHO_resource','ECHO_collection']) |
|
|
|
ret=getRDFDescription(self,self.absolute_url(),urn=urn) |
|
|
|
|
|
if not urn: |
|
urn=self.absolute_url() |
|
li="""<RDF:li RDF:resource="%s" />\n""" |
|
|
|
|
|
for content in contents: |
|
ret+=content[1].getRDF()+"\n" |
|
|
|
ret+="""<RDF:Seq RDF:about="%s">\n"""%urn |
|
for content in contents: |
|
nurn=content[1].absolute_url() |
|
ret+=li%nurn |
|
return ret+"</RDF:Seq>" |
|
|
def index_html(self): |
def index_html(self): |
"""standard page""" |
"""standard page""" |
displayedObjects=self.ZopeFind(self,obj_metatypes=displayTypes) |
displayedObjects=self.ZopeFind(self,obj_metatypes=displayTypes) |
Line 1893 class ECHO_group(ECHO_collection):
|
Line 2266 class ECHO_group(ECHO_collection):
|
return pt() |
return pt() |
|
|
def changeECHO_group(self,title,label,description,contentType,responsible,weight,secondaryLink,secondaryLinkTitle,credits=None,sortfield="weight",coords=None,RESPONSE=None,imageTag="",bgcolour="",logo=""): |
def changeECHO_group(self,title,label,description,contentType,responsible,weight,secondaryLink,secondaryLinkTitle,credits=None,sortfield="weight",coords=None,RESPONSE=None,imageTag="",bgcolour="",logo=""): |
"""Änderung der Properties""" |
"""Änderung der Properties""" |
|
|
self.secondaryLink=secondaryLink |
self.secondaryLink=secondaryLink |
self.secondaryLinkTitle=secondaryLinkTitle |
self.secondaryLinkTitle=secondaryLinkTitle |
Line 1926 class ECHO_group(ECHO_collection):
|
Line 2299 class ECHO_group(ECHO_collection):
|
|
|
def content_html(self): |
def content_html(self): |
"""template fuer content""" |
"""template fuer content""" |
return content_html(self,'group') |
return ECHO_basis.content_html(self,'group') |
|
|
|
|
|
|
Line 2064 def manage_addECHO_userFolderForm(self):
|
Line 2437 def manage_addECHO_userFolderForm(self):
|
"""add a user folder form""" |
"""add a user folder form""" |
return manage_addECHO_userFolder(self) |
return manage_addECHO_userFolder(self) |
|
|
|
|
|
|
|
def createNode(self,descrs,node): |
|
name=descrs[node]['name'] |
|
type=descrs[node]['type'] |
|
urn=node |
|
#print " will create",node.encode('utf-8') |
|
id=re.sub('[^a-zA-Z0-9]','',name).encode('ascii','ignore') |
|
#print "id",id |
|
#print type |
|
#self.REQUEST.RESPONSE.write("<p>%s<p>\n"%id) |
|
if type=="CDLI_group": |
|
|
|
try: |
|
manage_addECHO_collection(self,id,name,name,"","","","","") |
|
|
|
except: |
|
self.REQUEST.RESPONSE.write("<p>Error%s</p>\n"%id) |
|
|
|
self.REQUEST.RESPONSE.write("<p>Creates:%s</p>\n"%getattr(self,id).absolute_url()) |
|
|
|
return type,getattr(self,id),urn |
|
|
|
if type=="CDLI_item": |
|
try: |
|
manage_addECHO_resource(self,id,name,name,"","",urn,"","") |
|
except: |
|
self.REQUEST.RESPONSE.write("<p>Error%s</p>\n"%id) |
|
self.REQUEST.RESPONSE.write("<p>Creates:%s</p>\n"%getattr(self,id).absolute_url()) |
|
|
|
|
|
return "XX" |
|
|
|
|
class ECHO_root(Folder,Persistent,Implicit): |
class ECHO_root(Folder,Persistent,Implicit): |
"""ECHO Root Folder""" |
"""ECHO Root Folder""" |
|
|
Line 2071 class ECHO_root(Folder,Persistent,Implic
|
Line 2478 class ECHO_root(Folder,Persistent,Implic
|
|
|
meta_type="ECHO_root" |
meta_type="ECHO_root" |
|
|
|
###CDLI adds -> have to be removed |
|
def getTablet(self,item): |
|
#print "getTablet" |
|
try: |
|
read=urllib.urlopen("http://enlil.museum.upenn.edu/cgi-bin/cdlget.plx?item=%s&project=ncdl"%item).read() |
|
read=re.sub("\[search\]","search",read) |
|
return read[read.find("<body>")+6:read.rfind("</body>")] |
|
except: |
|
return "<h1>Sorry no connection to the data server enlil.museum.upenn.edu</h1>" |
|
#return "http://enlil.museum.upenn.edu/cgi-bin/cdlget.plx?item=%s&project=ncdl" |
|
###END CDLI add |
|
|
|
|
|
def checkResource(self,id): |
|
"""checks if a resource is in the tree, gives back none or list of resources""" |
|
if hasattr(self,"_v_checkResource") and self._v_checkResource.has_key(id): #existiert ein cache und id ist bereits drin? |
|
return self._v_checkResource[id] |
|
|
|
else: |
|
resources=self.ZopeFind(self,obj_metatypes=['ECHO_resource'],obj_ids=[id],search_sub=1) |
|
|
|
if not hasattr(self,"_v_checkResource"): self._v_checkResource={}#lege cache an falls nicht existent |
|
if resources: |
|
self._v_checkResource[id]=resources[0:] # slicing to be sure that data is stabil |
|
else: |
|
self._v_checkResource[id]=None |
|
|
|
return self._v_checkResource[id] |
|
|
|
def sendForm(self,fromaddr,content,server='mail.mpiwg-berlin.mpg.de'): |
|
"""sendform""" |
|
toaddrs=["dwinter@mpiwg-berlin.mpg.de"] |
|
|
|
msg = ("From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n" |
|
% (fromaddr, ", ".join(toaddrs),"testsub")) |
|
server = smtplib.SMTP(server) |
|
#server.set_debuglevel(1) |
|
msg=msg+content |
|
server.sendmail(fromaddr, toaddrs, msg) |
|
server.quit() |
|
|
|
def generateFromRDFForm(self): |
|
"""change form""" |
|
pt=PageTemplateFile('Products/ECHO_content/zpt/generateFromRDFForm').__of__(self) |
|
pt.content_type="text/html" |
|
return pt() |
|
|
|
def generateFromRDF(self,file,startNode="/Cuneiform Corpus"): |
|
|
|
"""generate from RDF""" |
|
|
|
global seqs |
|
seqs={} |
|
global descrs |
|
descrs={} |
|
global key |
|
key="" |
|
global value |
|
value="" |
|
|
|
def getEdges(seqs,urn): |
|
"""edges""" |
|
ret=[] |
|
return seqs[urn] |
|
|
|
def createSubs(self,seqs,descrs,urn,level=0): |
|
"""create subs""" |
|
for edge in getEdges(seqs,urn): |
|
cn=createNode(self,descrs,edge) |
|
if cn[0]=="CDLI_group": |
|
createSubs(cn[1],seqs,descrs,cn[2],level+1) |
|
return |
|
|
|
def start_element(name,attrs): |
|
|
|
global seqs |
|
global descrs |
|
global key |
|
global value |
|
seq="" |
|
if name=="RDF:Seq": |
|
key=attrs.get('RDF:about') |
|
try: # teste ob liste |
|
x=seqs[key][0] |
|
except: |
|
|
|
seqs[key]=[] |
|
|
|
|
|
elif name=="RDF:Description": |
|
key=attrs.get('RDF:about') |
|
|
|
|
|
elif name=="RDF:li": |
|
name=attrs.get('RDF:resource') |
|
seqs[key].append(name) |
|
|
|
elif name=="ECHONAVIGATION:type": |
|
value="type" |
|
|
|
elif name=="ECHONAVIGATION:name": |
|
value="name" |
|
elif name=="ECHONAVIGATION:linkClickable": |
|
value="linkClickable" |
|
|
|
def end_element(name): |
|
"""nothing""" |
|
key="" |
|
value="" |
|
|
|
def char_data(data): |
|
"""nothing""" |
|
|
|
data=re.sub("\n","",data) |
|
try: |
|
if descrs[key].has_key(value): |
|
descrs[key][value]+=data |
|
else: |
|
descrs[key][value]=data |
|
except: |
|
|
|
descrs[key]={} |
|
descrs[key][value]=data |
|
|
|
p = xml.parsers.expat.ParserCreate() |
|
|
|
p.StartElementHandler = start_element |
|
p.EndElementHandler = end_element |
|
p.CharacterDataHandler = char_data |
|
|
|
|
|
p.ParseFile(file) |
|
self.REQUEST.RESPONSE.write("<html><body><h1>Start</h1>") |
|
createSubs(self,seqs,descrs,startNode) |
|
self.REQUEST.RESPONSE.write("<h1>done</h1></body></html>") |
|
#print "done" |
|
|
|
|
|
return "done" |
|
|
|
|
|
|
|
|
|
def changeWeightsInCollection(self): |
|
"""change all lables of a collection""" |
|
ret="" |
|
argv=self.REQUEST.form |
|
|
|
resources=self.ZopeFind(self,obj_metatypes=['ECHO_resource','ECHO_collection','ECHO_link','ECHO_externalLink']) |
|
for resource in resources: |
|
|
|
try: |
|
ret+=resource[1].getId()+" "+argv[resource[1].getId()]+"</br>" |
|
resource[1].weight=argv[resource[1].getId()][0:] |
|
except: |
|
"""not""" |
|
return ret |
|
|
|
def changeWeights(self): |
|
"""change form""" |
|
pt=PageTemplateFile('Products/ECHO_content/zpt/changeWeightForm').__of__(self) |
|
pt.content_type="text/html" |
|
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): |
|
"""warning""" |
|
pt=PageTemplateFile('Products/ECHO_content/zpt/reloadMetaDataFromStorageWarning.zpt').__of__(self) |
|
pt.content_type="text/html" |
|
return pt() |
|
|
|
def reloadMetaDataFromStorage(self,RESPONSE=None): |
|
"""reload MD from Storage""" |
|
|
|
return reloadMetaDataFromStorage(self,RESPONSE) |
|
|
|
def getRDF(self,urn=None): |
|
"""rdf of the collection""" |
|
|
|
contents=self.ZopeFind(self,obj_metatypes=['ECHO_group','ECHO_resource','ECHO_collection']) |
|
|
|
ret=getRDFDescription(self,self.absolute_url(),urn=urn) |
|
|
|
li="""<RDF:li RDF:resource="%s" />\n""" |
|
|
|
|
|
for content in contents: |
|
ret+=content[1].getRDF()+"\n" |
|
|
|
ret+="""<RDF:Seq RDF:about="%s">\n"""%urn |
|
for content in contents: |
|
nurn=content[1].absolute_url() |
|
ret+=li%nurn |
|
return ret+"</RDF:Seq>" |
|
|
|
|
|
def showContent(self,path): |
|
"""return content/html""" |
|
|
|
return ECHO_helpers.urlopen(path+"/content_html").read() |
|
|
|
def getImageViewers(self): |
|
"""images""" |
|
viewers=self.ZopeFind(self.standardImageViewer,obj_metatypes=['OSAS_ViewerObject']) |
|
return viewers |
|
|
|
|
def getBibTag(self,tag,content): |
def getBibTag(self,tag,content): |
"""get field tag für index-meta-generation""" |
"""get field tag für index-meta-generation""" |
if not content or content=="": |
if not content or content=="": |
return "" |
return "" |
ret="<%s>"%tag |
ret="<%s>"%tag |
Line 2161 class ECHO_root(Folder,Persistent,Implic
|
Line 2784 class ECHO_root(Folder,Persistent,Implic
|
return retStr |
return retStr |
|
|
|
|
def copyrightTypeSelector_HTML(self,selected=None,first=None): |
def copyrightTypeSelector_HTML(self, object=None, selected=None,first=None): |
"""give type selector""" |
"""give type selector""" |
|
|
if not first: |
if not first: |
Line 2182 class ECHO_root(Folder,Persistent,Implic
|
Line 2805 class ECHO_root(Folder,Persistent,Implic
|
retStr+="""<option selected value="%s">%s\n"""%(copyrightType[0],copyrightType[0]) |
retStr+="""<option selected value="%s">%s\n"""%(copyrightType[0],copyrightType[0]) |
else: |
else: |
retStr+="""<option value="%s">%s\n"""%(copyrightType[0],copyrightType[0]) |
retStr+="""<option value="%s">%s\n"""%(copyrightType[0],copyrightType[0]) |
|
|
|
for copyrightTypeSelf in self.ZopeFind(object,obj_metatypes=["ECHO_copyrightType"],search_sub=1): |
|
if selected and (copyrightTypeSelf[0]==selected): |
|
retStr+="""<option selected value="%s">%s\n"""%(copyrightTypeSelf[0],copyrightTypeSelf[0]) |
|
else: |
|
retStr+="""<option value="%s">%s\n"""%(copyrightTypeSelf[0],copyrightTypeSelf[0]) |
|
|
except: |
except: |
"""nothing""" |
"""nothing""" |
|
|
return retStr |
return retStr |
|
|
def partnerSelector_HTML(self,selected=None): |
def partnerSelector_HTML(self,selected=None): |
Line 2203 class ECHO_root(Folder,Persistent,Implic
|
Line 2834 class ECHO_root(Folder,Persistent,Implic
|
"""nothing""" |
"""nothing""" |
return retStr |
return retStr |
|
|
mediaTypes=['all','text','images','sound','video'] # konfigurierbar in neuer version über echoroot?? |
mediaTypes=['all','text','images','sound','video'] # konfigurierbar in neuer version über echoroot?? |
|
|
def mediaTypeSelector_HTML(self,selected=None): |
def mediaTypeSelector_HTML(self,selected=None): |
"""give type selector""" |
"""give type selector""" |
Line 2275 class ECHO_root(Folder,Persistent,Implic
|
Line 2906 class ECHO_root(Folder,Persistent,Implic
|
|
|
return "changed all contenttypes in: "+self.title |
return "changed all contenttypes in: "+self.title |
|
|
|
def deleteCache(self,obj=None,RESPONSE=None): |
|
"""setze alle collections auf cache = CacheManager""" |
|
|
|
|
|
if not obj: |
|
obj = self |
|
|
|
entries=obj.ZopeFind(obj,search_sub=1) |
|
|
|
for entry in entries: |
|
if hasattr(entry[1],'_v_hash'): |
|
entry[1]._v_hash=None |
|
|
|
|
|
|
|
|
|
return "changed all CM in: "+self.title |
|
|
|
|
|
|
def ECHO_newViewerLink(self,obj=None): |
def ECHO_newViewerLink(self,obj=None): |
"""change links (:86 faellt weg)""" |
"""change links (:86 faellt weg)""" |
|
|
Line 2341 class ECHO_root(Folder,Persistent,Implic
|
Line 2992 class ECHO_root(Folder,Persistent,Implic
|
for link in links: |
for link in links: |
link.tagName="a" |
link.tagName="a" |
ref=link.getAttribute("ref") |
ref=link.getAttribute("ref") |
|
pn=link.getAttribute("page") |
|
|
if self.checkRef(ref): |
if self.checkRef(ref): |
link.setAttribute("href",self.aq_parent.absolute_url()+"/vlp_coll?id="+ref) |
if pn: |
|
link.setAttribute("href",self.aq_parent.absolute_url()+"/references?id="+ref+"&p="+pn) |
|
else: |
|
link.setAttribute("href",self.aq_parent.absolute_url()+"/references?id="+ref) |
|
|
|
|
newxml=dom.toxml('utf-8') |
newxml=dom.toxml('utf-8') |
match=re.sub(r'<\?xml version=\"1.0\" encoding=\"utf-8\"\?>\n<txt>','',newxml) |
|
match=re.sub(r'</txt>','',match) |
|
|
|
return match |
retStr=regexpTXT.search(newxml) |
|
|
|
return retStr.group(1) |
|
|
|
|
return "" |
return "" |
|
|
def xml2html(self,str): |
def xml2html(self,str,quote="yes"): |
"""link2html fuer VLP muss hier noch raus""" |
"""link2html fuer VLP muss hier noch raus""" |
if str: |
|
|
|
|
if str: |
|
if quote=="yes2": |
str=re.sub("\&","&",str) |
str=re.sub("\&","&",str) |
dom=xml.dom.minidom.parseString(str) |
#dom=xml.dom.minidom.parseString(str) |
links=dom.getElementsByTagName("link") |
dom = NonvalidatingReader.parseString(str,"http://www.mpiwg-berlin.mpg.de/") |
|
#links=dom.getElementsByTagName("link") |
|
links=Ft.Xml.XPath.Evaluate(".//link", contextNode=dom) |
|
for link in links: |
|
#link.tagName="a" |
|
|
|
ref=link.getAttributeNS(EMPTY_NAMESPACE,"ref") |
|
pn=link.getAttributeNS(EMPTY_NAMESPACE,"page") |
|
|
for link in links: |
cns=link.childNodes[0:] |
link.tagName="a" |
|
ref=link.getAttribute("ref") |
newLink=dom.createElementNS(EMPTY_NAMESPACE,"a") |
|
for x in cns: |
|
newLink.appendChild(x) |
|
|
|
|
|
|
|
link.parentNode.replaceChild(newLink,link) |
if self.checkRef(ref): |
if self.checkRef(ref): |
link.setAttribute("href",self.aq_parent.absolute_url()+"/vlp_coll?id="+ref) |
if pn: |
|
newLink.setAttributeNS(EMPTY_NAMESPACE,"href",self.aq_parent.absolute_url()+"/vlp_coll?id="+ref+"&p="+pn) |
|
else: |
|
newLink.setAttributeNS(EMPTY_NAMESPACE,"href",self.aq_parent.absolute_url()+"/vlp_coll?id="+ref) |
|
|
return dom.toxml('utf-8') |
#str= dom.toxml('utf-8') |
|
buf = cStringIO.StringIO() |
|
PrettyPrint(dom, stream=buf, encoding='UTF-8') |
|
str = buf.getvalue() |
|
buf.close() |
|
#str=PrettyPrint(dom.documentElement,encoding='UTF-8') |
|
#print link.toxml('utf-8') |
|
#print type(str) |
|
retStr=regexpPage.search(str) |
|
try: # hack warum fehtl manchmal page?? |
|
return retStr.group(1) |
|
except: |
|
return str |
return "" |
return "" |
|
|
def checkRef(self,ref): |
def checkRef(self,ref): |
dbs={'vl_literature':'AND CD LIKE \'%lise%\'','vl_technology':'','vl_people':''} |
if ref[0:3]=='lit': |
|
if len(self.library_data({ 'id':ref}))>0: |
|
return 1 |
|
try: |
|
if ref[0:7]=="tec_cat": |
|
return 1 |
|
except: |
|
"""nothing""" |
|
|
|
dbs={'vl_technology':'','vl_people':'','vl_sites':''} |
res=None |
res=None |
for db in dbs.keys(): |
for db in dbs.keys(): |
|
|
res=res or self.search(var=str("select reference from %s where reference =\'%s\' %s"%(db,ref,dbs[db]))) |
res=res or self.search(var=str("select reference from %s where reference =\'%s\' %s"%(db,ref,dbs[db]))) |
return res |
return res |
|
|
Line 2387 class ECHO_root(Folder,Persistent,Implic
|
Line 3081 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'): |
return [ item[1] for item in self.partners.ZopeFind(self.partners,obj_metatypes=['ECHO_partner'])] |
return [ item[1] for item in self.partners.ZopeFind(self.partners,obj_metatypes=['ECHO_partner'])] |
|
else: |
|
return [] |
|
|
|
def getInstitutions(self): |
|
"""Get list of Partners. Presently only from a subfolder partners""" |
|
|
|
return [ item[1] for item in self.institutions.ZopeFind(self.institutions,obj_metatypes=['ECHO_institution'])] |
|
|
|
|
def getPartnersXML(self): |
def getPartnersXML(self): |
Line 2401 class ECHO_root(Folder,Persistent,Implic
|
Line 3099 class ECHO_root(Folder,Persistent,Implic
|
<partners>""" |
<partners>""" |
|
|
for partner in partners: |
for partner in partners: |
ret+="""<partner id="%s" title="%s"/>\n"""%(partner.getId(),unicode(partner.title,'utf-8','replace')) |
ret+="""<partner id="%s" title="%s"/>\n"""%(partner.getId(),partner.title) |
|
|
return ret+"\n</partners>" |
return ret+"\n</partners>" |
|
|
Line 2508 class ECHO_root(Folder,Persistent,Implic
|
Line 3206 class ECHO_root(Folder,Persistent,Implic
|
|
|
def getMetaDatasXML(self,viewerType=None,filter=None): |
def getMetaDatasXML(self,viewerType=None,filter=None): |
"""gebe all ressourcen aus""" |
"""gebe all ressourcen aus""" |
|
# check if the request's host part was OK |
|
http_host = self.REQUEST['HTTP_HOST'] |
|
host_port = self.REQUEST['SERVER_PORT'] |
|
fix_host = None |
|
if http_host and http_host.rfind(host_port) == -1: |
|
print "HTTP_HOST needs fixing!" |
|
fix_host = http_host + ":" + host_port |
|
|
ret="""<?xml version="1.0" ?> |
ret="""<?xml version="1.0" ?> |
<index>""" |
<index>""" |
for resource in self.ZopeFind(self,obj_metatypes=['ECHO_resource'],search_sub=1): |
for resource in self.ZopeFind(self,obj_metatypes=['ECHO_resource'],search_sub=1): |
|
|
echo_url=resource[1].absolute_url() |
echo_url=resource[1].absolute_url() |
if resource[1].getFullTextXML(noredirect="yes"): |
if fix_host: |
|
#print "replacing ", http_host, " by ", fix_host |
|
echo_url = string.replace(echo_url, http_host, fix_host, 1) |
|
|
if hasattr(resource[1],'link'): |
if hasattr(resource[1],'link'): |
viewer_url=echo_url+"/getMetaDataXML" |
meta_url=echo_url+"/getMetaDataXML" |
else: |
else: |
viewer_url="NO URL" |
meta_url="NO_URL" |
if filter: |
|
if re.search(filter,viewer_url): |
|
ret+="""\n<resource echoLink="%s" viewerLink="%s"/>"""%(urllib.quote(echo_url,safe='/:?'),urllib.quote(viewer_url,safe='/:?')) |
|
else: |
|
ret+="""\n<resource echoLink="%s" viewerLink="%s"/>"""%(urllib.quote(echo_url,safe='/:?'),urllib.quote(viewer_url,safe='/:?')) |
|
ret +="""\n</index>""" |
|
|
|
|
if filter and not re.search(filter,viewer_url): |
|
continue |
|
|
|
#modificationDate=time.strptime(str(resource[1].bobobase_modification_time()),"%Y/%m/%d %H:%M:%S %Z") |
|
|
|
modificationDate=resource[1].bobobase_modification_time().strftime("%Y/%m/%d %H:%M:%S") |
|
|
|
ret+="""\n<resource resourceLink="%s" metaLink="%s" modificationDate="%s"/>"""%(urllib.quote(echo_url,safe='/:?'),urllib.quote(meta_url,safe='/:?'),modificationDate) |
|
|
|
|
|
ret +="""\n</index>""" |
|
|
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) |
Line 2546 class ECHO_root(Folder,Persistent,Implic
|
Line 3260 class ECHO_root(Folder,Persistent,Implic
|
par=self.ZopeFind(self.partners, obj_ids=[id]) |
par=self.ZopeFind(self.partners, obj_ids=[id]) |
return par |
return par |
|
|
|
def getInstitutionFromID(self,id): |
|
""" find institution from id """ |
|
inst=self.ZopeFind(self.institutions, obj_ids=[id]) |
|
return inst |
|
|
|
|
def manage_addECHO_root(self,id,title,RESPONSE=None): |
def manage_addECHO_root(self,id,title,RESPONSE=None): |
Line 2560 def manage_addECHO_rootForm(self):
|
Line 3278 def manage_addECHO_rootForm(self):
|
pt=PageTemplateFile('Products/ECHO_content/zpt/AddECHO_root.zpt').__of__(self) |
pt=PageTemplateFile('Products/ECHO_content/zpt/AddECHO_root.zpt').__of__(self) |
return pt() |
return pt() |
|
|
class ECHO_copyrightType(Folder): |
class ECHO_copyrightType(Folder,ECHO_basis): |
"""copyright typ""" |
"""copyright typ""" |
|
|
meta_type="ECHO_copyrightType" |
meta_type="ECHO_copyrightType" |
Line 2609 def manage_addECHO_copyrightType(self,id
|
Line 3327 def manage_addECHO_copyrightType(self,id
|
|
|
|
|
|
|
class ECHO_partner(Image,Persistent): |
class ECHO_partner(Image,Persistent,ECHO_basis): |
"""ECHO Partner""" |
"""ECHO Partner""" |
|
|
meta_type="ECHO_partner" |
meta_type="ECHO_partner" |
|
|
def __init__(self, id, title,url, file, copyrightType, person, email, country, content_type='', precondition=''): |
def __init__(self, id, title,url, file, copyrightType, person, email, country, color, content_type='', precondition=''): |
self.__name__=id |
self.__name__=id |
self.title=title |
self.title=title |
self.url=url |
self.url=url |
self.person=person |
self.person=person |
self.email=email |
self.email=email |
self.country=country |
self.country=country |
|
self.color=color |
self.precondition=precondition |
self.precondition=precondition |
self.copyrightType=copyrightType |
self.copyrightType=copyrightType |
data, size = self._read_data(file) |
data, size = self._read_data(file) |
Line 2632 class ECHO_partner(Image,Persistent):
|
Line 3351 class ECHO_partner(Image,Persistent):
|
) |
) |
|
|
|
|
def changeECHO_partner(self,url,copyrightType,person, email, country, RESPONSE=None): |
def changeECHO_partner(self,url,copyrightType,person, email, country, color, RESPONSE=None): |
"""Change main information""" |
"""Change main information""" |
self.url=url |
self.url=url |
self.person=person |
self.person=person |
self.email=email |
self.email=email |
self.country=country |
self.country=country |
|
self.color=color |
self.copyrightType=copyrightType |
self.copyrightType=copyrightType |
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
Line 2657 manage_addECHO_partnerForm=DTMLFile('dtm
|
Line 3377 manage_addECHO_partnerForm=DTMLFile('dtm
|
|
|
|
|
|
|
def manage_addECHO_partner(self, id,file,url, person, email, country, copyrightType='', title='', precondition='', content_type='', |
def manage_addECHO_partner(self, id, url, person, email, country, color, file=None, copyrightType='', title='', precondition='', content_type='', |
REQUEST=None): |
REQUEST=None): |
""" |
""" |
Add a new ECHO_partner object. |
Add a new ECHO_partner object. |
Line 2676 def manage_addECHO_partner(self, id,file
|
Line 3396 def manage_addECHO_partner(self, id,file
|
self=self.this() |
self=self.this() |
|
|
# First, we create the image without data: |
# First, we create the image without data: |
self._setObject(id, ECHO_partner(id,title,url,'',copyrightType, person, email, country, content_type, precondition)) |
self._setObject(id, ECHO_partner(id,title,url,'',copyrightType, person, email, country, color, content_type, precondition)) |
|
|
# Now we "upload" the data. By doing this in two steps, we |
# Now we "upload" the data. By doing this in two steps, we |
# can use a database trick to make the upload more efficient. |
# can use a database trick to make the upload more efficient. |
Line 2691 def manage_addECHO_partner(self, id,file
|
Line 3411 def manage_addECHO_partner(self, id,file
|
REQUEST.RESPONSE.redirect('%s/manage_main' % url) |
REQUEST.RESPONSE.redirect('%s/manage_main' % url) |
return id |
return id |
|
|
|
class ECHO_linkList(ZopePageTemplate,ECHO_basis): |
|
"""LinkList Objekt""" |
|
meta_type="ECHO_linkList" |
|
|
|
_default_content_fn = os.path.join(package_home(globals()), 'html/ECHO_pageTemplateDefault.html') |
|
|
|
manage_options = ZopePageTemplate.manage_options+( |
|
{'label':'Main Config','action':'changeECHO_linkListWeightForm'}, |
|
) |
|
|
|
def content_html(self): |
|
"""content_html""" |
|
return ECHO_basis.content_html(self,'pageTemplate') |
|
|
|
def changeECHO_linkListWeightForm(self): |
|
"""change""" |
|
pt=PageTemplateFile('Products/ECHO_content/zpt/ChangeECHO_linkListTemplate.zpt').__of__(self) |
|
return pt() |
|
|
|
def changeECHO_linkListWeight(self,contentType,label,RESPONSE=None): |
|
"""change""" |
|
self.contentType=contentType |
|
self.label=label |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
def getLabel(self): |
|
if hasattr(self,'label'): |
|
return self.label.encode('utf-8') |
|
else: |
|
return 0 |
|
|
|
def getcontentType(self): |
|
"""get contentType""" |
|
if hasattr(self,'contentType'): |
|
return self.contentType |
|
else: |
|
return 0 |
|
|
|
def __init__(self, id, label, title=None, text=None, contentType=None): |
|
self.id = str(id) |
|
self.title=title |
|
self.label=label |
|
self.ZBindings_edit(self._default_bindings) |
|
if text is None: |
|
text = '' |
|
self.pt_edit(text, contentType) |
|
|
|
|
|
|
|
|
|
def manage_addECHO_linkListForm(self): |
|
"""Form for adding""" |
|
pt=PageTemplateFile('Products/ECHO_content/zpt/AddECHO_linkListTemplate.zpt').__of__(self) |
|
return pt() |
|
|
|
from urllib import quote |
|
|
|
|
|
def manage_addECHO_linkList(self, id, label,contentType=0,title=None, text=None, |
|
REQUEST=None, submit=None): |
|
"""Add a LinkList with optional file content.""" |
|
|
|
id = str(id) |
|
if REQUEST is None: |
|
self._setObject(id, ECHO_linkList(id, label, text)) |
|
ob = getattr(self, id) |
|
setattr(ob,'contentType',contentType) |
|
if title: |
|
ob.pt_setTitle(title) |
|
return ob |
|
else: |
|
file = REQUEST.form.get('file') |
|
headers = getattr(file, 'headers', None) |
|
if (headers is None) or (not file.filename): |
|
zpt = ECHO_linkList(id, file) |
|
else: |
|
zpt = ECHO_linkList(id, label,'', file, headers.get('contentType')) |
|
|
|
self._setObject(id, zpt) |
|
ob = getattr(self, id) |
|
if title: |
|
ob.pt_setTitle(title) |
|
|
|
try: |
|
u = self.DestinationURL() |
|
except AttributeError: |
|
u = REQUEST['URL1'] |
|
|
|
if submit == " Add and Edit ": |
|
u = "%s/%s" % (u, quote(id)) |
|
REQUEST.RESPONSE.redirect(u+'/manage_main') |
|
return '' |
|
|
|
|
|
class ECHO_support(Folder,ECHO_basis): |
|
"""gefoerdert durch""" |
|
meta_type="ECHO_support" |
|
|
|
|
|
|
|
def __init__(self,id,institutions=None): |
|
"""init""" |
|
self.id=id |
|
self.title='' |
|
self.institutions=toList(institutions) |
|
|
|
def getSupporter(self): |
|
"""return institutions""" |
|
if self.institutions: |
|
return self.institutions |
|
else: |
|
return [] |
|
|
|
manage_options = Folder.manage_options+( |
|
{'label':'Main Config','action':'ECHO_support_configForm'}, |
|
) |
|
|
|
def ECHO_support_configForm(self): |
|
"""change form""" |
|
pt=PageTemplateFile('Products/ECHO_content/zpt/ChangeECHO_support').__of__(self) |
|
pt.content_type="text/html" |
|
return pt() |
|
|
|
def ECHO_support_config(self,institutions=None,RESPONSE=None): |
|
"""change""" |
|
self.institutions=toList(institutions) |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
|
|
def manage_addECHO_supportForm(self): |
|
"""Form for adding""" |
|
pt=PageTemplateFile('Products/ECHO_content/zpt/AddECHO_support.zpt').__of__(self) |
|
return pt() |
|
|
|
def manage_addECHO_support(self, id,institutions=None,RESPONSE=None): |
|
"""add the copyright""" |
|
|
|
meta_type="ECHO_support" |
|
|
|
|
|
self._setObject(id, ECHO_support(id,institutions)) |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
|
|
class ECHO_institution(Image,Persistent,ECHO_basis): |
|
"""ECHO Institution""" |
|
|
|
meta_type="ECHO_institution" |
|
|
|
def __init__(self, id, title,url, file, person, email, country, content_type='', precondition=''): |
|
self.__name__=id |
|
self.title=title |
|
self.url=url |
|
self.person=person |
|
self.email=email |
|
self.country=country |
|
self.precondition=precondition |
|
data, size = self._read_data(file) |
|
content_type=self._get_content_type(file, data, id, content_type) |
|
self.update_data(data, content_type, size) |
|
|
|
manage_options = Image.manage_options+( |
|
{'label':'Institution Information','action':'ECHO_institution_config'}, |
|
) |
|
|
|
|
|
def changeECHO_institution(self,url,person, email, country,RESPONSE=None): |
|
"""Change main information""" |
|
self.url=url |
|
self.person=person |
|
self.email=email |
|
self.country=country |
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
|
|
|
|
def ECHO_institution_config(self): |
|
"""Main configuration""" |
|
if not hasattr(self,'url'): |
|
self.url="" |
|
pt=PageTemplateFile('Products/ECHO_content/zpt/ChangeECHO_institution.zpt').__of__(self) |
|
return pt() |
|
|
|
|
|
manage_addECHO_institutionForm=DTMLFile('dtml/ECHO_institutionAdd',globals(), |
|
Kind='ECHO_institution',kind='ECHO_institution') |
|
|
|
|
|
|
|
def manage_addECHO_institution(self, id, url, person, email, country, file=None, title='', precondition='', content_type='', |
|
REQUEST=None): |
|
""" |
|
Add a new ECHO_institution object. |
|
|
|
Creates a new ECHO_institution object 'id' with the contents of 'file'. |
|
Based on Image.manage_addImage |
|
""" |
|
|
|
id=str(id) |
|
title=str(title) |
|
content_type=str(content_type) |
|
precondition=str(precondition) |
|
|
|
id, title = OFS.Image.cookId(id, title, file) |
|
|
|
self=self.this() |
|
|
|
# First, we create the image without data: |
|
self._setObject(id, ECHO_institution(id,title,url,'', person, email, country, content_type, precondition)) |
|
|
|
# Now we "upload" the data. By doing this in two steps, we |
|
# can use a database trick to make the upload more efficient. |
|
if file: |
|
self._getOb(id).manage_upload(file) |
|
if content_type: |
|
self._getOb(id).content_type=content_type |
|
|
|
if REQUEST is not None: |
|
try: url=self.DestinationURL() |
|
except: url=REQUEST['URL1'] |
|
REQUEST.RESPONSE.redirect('%s/manage_main' % url) |
|
return id |
|
|