|
|
| version 1.27, 2004/04/04 14:56:05 | version 1.310.2.8, 2012/08/29 07:53:31 |
|---|---|
| Line 1 | Line 1 |
| """New version of the product started February, 8th. Without scientific classification, use content-type for further classification.""" | """New version of the produc started February, 8th. Without scientific classification, use content-type for further classification.""" |
| """Echo collection provides the classes for the ECHO content web-site. | """Echo collection provides the classes for the ECHO content web-site. |
| class ECHO_collection is the basis class for an ECHO collection. | class ECHO_collection is the basis class for an ECHO collection. |
| Line 9 class ECHO_externalLink contains informa | Line 9 class ECHO_externalLink contains informa |
| """ | """ |
| import urlparse | |
| import string | import string |
| import tempfile | |
| import zipfile | |
| import re | import re |
| import os,shutil | |
| 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 |
| from OFS.SimpleItem import SimpleItem | from OFS.SimpleItem import SimpleItem |
| from AccessControl import ClassSecurityInfo | from AccessControl import ClassSecurityInfo |
| from AccessControl.User import UserFolder | |
| from Globals import InitializeClass | from Globals import InitializeClass |
| from Globals import DTMLFile | from Globals import DTMLFile |
| import Globals | |
| from Products.PageTemplates.PageTemplateFile import PageTemplateFile | from Products.PageTemplates.PageTemplateFile import PageTemplateFile |
| from Products.PageTemplates.PageTemplate import PageTemplate | from Products.PageTemplates.PageTemplate import PageTemplate |
| from Globals import Persistent | from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate,manage_addPageTemplate |
| from Globals import Persistent, package_home | |
| from Acquisition import Implicit | from Acquisition import Implicit |
| #from psycopg import libpq | from Products.ZCatalog.CatalogPathAwareness import CatalogAware |
| #from pyPgSQL import libpq | from Products.ZCTextIndex.ZCTextIndex import manage_addLexicon |
| import xml.dom.minidom | import ECHO_helpers |
| from Acquisition import aq_parent | |
| try: | |
| from Products.MetaDataProvider.MetaDataClient import MetaDataClient | |
| except: | |
| print "no metadataclient" | |
| import urllib | import urllib |
| import xml.dom.minidom | import urllib2 |
| from ECHO_graphicalOverview import javaHandler,javaScriptMain | import cgi |
| import smtplib | |
| #List of different types for the graphical linking viewer | import time |
| viewClassificationListMaster=['view point','area'] | #from Ft.Xml.Domlette import NonvalidatingReader |
| #from Ft.Xml.Domlette import PrettyPrint, Print | |
| #from Ft.Xml import EMPTY_NAMESPACE | |
| def toList(field): | # |
| """Einzelfeld in Liste umwandeln""" | #import Ft.Xml.XPath |
| if type(field)==StringType: | import cStringIO |
| return [field] | |
| else: | |
| return field | |
| def getText(nodelist): | |
| rc = "" | import sys |
| for node in nodelist: | import logging |
| if node.nodeType == node.TEXT_NODE: | |
| rc = rc + node.data | |
| return rc | |
| def readMetadata(url): | |
| """Methoden zum Auslesen der Metadateninformation zu einer Resource | |
| Vorerst noch Typ bib""" | |
| metadict={} | |
| try: | try: |
| geturl="" | from psycopg import libpq |
| for line in urllib.urlopen(url).readlines(): | |
| geturl=geturl+line | |
| except: | except: |
| return (None,"Cannot open: "+url) | |
| try: | try: |
| dom=xml.dom.minidom.parseString(geturl) | from pyPgSQL import libpq |
| except: | except: |
| return (None,"Cannot parse: "+url+"<br>"+geturl) | print "ECHO_collection: Warning - No libpq imported!" |
| metanode=dom.getElementsByTagName('bib') | import xml.dom.minidom |
| metadict['bib_type']='Book' | |
| if len(metanode)==0: | |
| metanode=dom.getElementsByTagName('archimedes') | |
| metadict['bib_type']='Archimedes' | |
| #print "HELLO" | |
| if not len(metanode)==0: | import urllib |
| metacontent=metanode[0].childNodes | import xml.dom.minidom |
| import ECHO_helpers | |
| from ECHO_helpers import * | |
| try: | try: |
| metadict['bib_type']=getText(dom.getElementsByTagName('bib')[0].attributes['type'].childNodes) | from ECHO_language import * |
| except: | except: |
| """nothing""" | print "no echo_language" |
| class ECHO_language: | |
| """ leere Klasse""" | |
| pass | |
| for node in metacontent: | from ECHO_movie import * |
| try: | #import vlp_xmlhelpers #TODO: vlp elemente aus echo herausnehmen |
| metadict[node.tagName.lower()]=getText(node.childNodes) | import xmlrpclib |
| except: | |
| """nothing""" | |
| #print metadict | import logging |
| return metadict,"" | |
| from ECHO_root import ECHO_root | |
| def setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight,coordstrs,viewClassification=""): | #ersetzt logging.info |
| def logger(txt,method,txt2): | |
| """logging""" | |
| logging.info(txt+ txt2) | |
| """Allegemeine Informationen zu einer ECHO Collection""" | |
| self.viewClassification=viewClassification | def setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight,coordstrs=""): |
| """Allegemeine Informationen zu einer ECHO Collection""" | |
| self.label = label | self.label = label |
| self.title=title | self.title=title |
| Line 110 def setECHO_collectionInformation(self,t | Line 106 def setECHO_collectionInformation(self,t |
| self.credits=toList(credits) | self.credits=toList(credits) |
| self.weight=weight | self.weight=weight |
| coords=[] | import ECHO_resource |
| #coordinates of for rectangles | from ECHO_resource import manage_addECHO_resource |
| #print "cs", coordstrs | class ECHO_resource(ECHO_resource.ECHO_resource): |
| if coordstrs: | """depricated use class in ECHO_resource.py""" |
| for coordstr in coordstrs: | |
| #print "cs", coordstr | |
| try: | |
| temco=coordstr.split(",") | |
| except: | |
| temco=[] | |
| #temco.append(angle) | |
| coords.append(temco) | |
| self.coords=coords[0:] | class ECHO_partner(Image,Persistent,ECHO_basis): |
| """ECHO Partner""" | |
| meta_type="ECHO_partner" | |
| class scientificClassification(SimpleItem,Persistent,Implicit): | def __init__(self, id, title,url, file, copyrightType, person, email, country, color, content_type='', precondition=''): |
| """outdated will be deleeted in the next versions: subclass""" | self.__name__=id |
| security=ClassSecurityInfo() | self.title=title |
| self.url=url | |
| self.person=person | |
| self.email=email | |
| self.country=country | |
| self.color=color | |
| self.precondition=precondition | |
| self.copyrightType=copyrightType | |
| data, size = self._read_data(file) | |
| content_type=self._get_content_type(file, data, id, content_type) | |
| self.update_data(data, content_type, size) | |
| def __init__(self,context,science,practice): | manage_options = Image.manage_options+( |
| self.context=context | {'label':'Partner Information','action':'ECHO_partner_config'}, |
| self.science=science | ) |
| self.practice=practice | |
| self.id="scientific_Classification" | |
| security.declarePublic('get_context') | |
| def get_context(self): | |
| return self.context | |
| security.declarePublic('get_science') | |
| def get_science(self): | |
| return self.science | |
| security.declarePublic('get_practice') | |
| def get_practice(self): | |
| return self.practice | |
| class scientificInformation(Folder,Persistent,Implicit): | def changeECHO_partner(self,url,copyrightType,person, email, country, color, RESPONSE=None): |
| """outdated will be deleted in the next versions: subclass scientificInformation""" | """Change main information""" |
| security=ClassSecurityInfo() | self.url=url |
| self.person=person | |
| self.email=email | |
| self.country=country | |
| self.color=color | |
| self.copyrightType=copyrightType | |
| if RESPONSE is not None: | |
| RESPONSE.redirect('manage_main') | |
| def __init__(self,source_type,period): | def ECHO_partner_config(self): |
| """Main configuration""" | |
| if not hasattr(self,'url'): | |
| self.url="" | |
| pt=zptFile(self, 'zpt/ChangeECHO_partner.zpt') | |
| return pt() | |
| self.id="scientific_Information" | |
| self.source_type=source_type | |
| self.period=period | |
| manage_addECHO_partnerForm=DTMLFile('dtml/ECHO_partnerAdd',globals(), | |
| Kind='ECHO_partner',kind='ECHO_partner') | |
| security.declarePublic('get_source_type') | |
| def get_source_type(self): | |
| return self.source_type | |
| security.declarePublic('get_period') | def manage_addECHO_partner(self, id, url, person, email, country, color, file=None, copyrightType='', title='', precondition='', content_type='', |
| def get_period(self): | REQUEST=None): |
| return self.period | """ |
| Add a new ECHO_partner object. | |
| Creates a new ECHO_partner object 'id' with the contents of 'file'. | |
| Based on Image.manage_addImage | |
| """ | |
| class ECHO_resource(Folder): | id=str(id) |
| """ECHO Ressource""" | title=str(title) |
| meta_type='ECHO_resource' | content_type=str(content_type) |
| precondition=str(precondition) | |
| viewClassificationList=viewClassificationListMaster | id, title = OFS.Image.cookId(id, title, file) |
| def getViewClassification(self): | self=self.this() |
| if hasattr(self,'viewClassification'): | |
| return self.viewClassification | |
| else: | |
| return "" | |
| def getCredits(self): | # First, we create the image without data: |
| """Ausgabe der credits""" | self._setObject(id, ECHO_partner(id,title,url,'',copyrightType, person, email, country, color, content_type, precondition)) |
| if self.credits: | |
| return self.credits | |
| else: | |
| return [] | |
| def __init__(self,id,link,metalink,title,label,description,contentType,responsible,credits,weight,coords): | # 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 | |
| self.id = id | if REQUEST is not None: |
| """Festlegen der ID""" | try: url=self.DestinationURL() |
| except: url=REQUEST['URL1'] | |
| REQUEST.RESPONSE.redirect('%s/manage_main' % url) | |
| return id | |
| self.label = label | class ECHO_locale(ZopePageTemplate): |
| self.link= link | """localisierung""" |
| self.metalink=metalink | |
| self.title=title | |
| self.weight=weight | |
| self.credits=toList(credits) | |
| self.description=description | |
| self.contentType=contentType | |
| self.responsible=responsible | |
| if coords: | meta_type="ECHO_locale" |
| coordsnew=[ string.split(x,",") for x in coords] | |
| else: | |
| coordsnew=[] | |
| self.coords=coordsnew | def __init__(self,id,lang,title,label,text=None,content_type=None): |
| self.lang=lang | |
| self.title=title | |
| self.label=label | |
| # default content | |
| if not text: | |
| text = open(self._default_content_fn).read() | |
| content_type = 'text/html' | |
| self.pt_edit(text, content_type) | |
| self.id=id | |
| manage_options = ZopePageTemplate.manage_options+( | |
| {'label':'Main Config','action':'change_ECHO_localeForm'}, | |
| ) | |
| def getCoords(self): | def change_ECHO_localeForm(self): |
| try: | """change form""" |
| return [string.join(x,",") for x in self.coords] | pt=zptFile(self, 'zpt/ChangeECHO_localeForm.zpt') |
| except: | return pt() |
| return [] | |
| def change_ECHO_locale(self,lang,title,label,text=None,content_type=None,RESPONSE=None): | |
| """change echo locale""" | |
| self.lang=lang | |
| self.title=title | |
| self.label=label | |
| if not text is None: | |
| if content_type is None: | |
| content_type = self.content_type | |
| self.pt_edit(text, content_type) | |
| def ECHO_resource_config(self): | if RESPONSE is not None: |
| """Main configuration""" | RESPONSE.redirect('manage_main') |
| if not hasattr(self,'weight'): | |
| self.weight="" | |
| if not hasattr(self,'coords'): | |
| self.coords=[] | |
| print "vorher",self.coords | def manage_addECHO_localeForm(self): |
| pt=PageTemplateFile('Products/ECHO_content/zpt/ChangeECHO_resource.zpt').__of__(self) | """Form for adding""" |
| pt=zptFile(self, 'zpt/AddECHO_localeForm.zpt') | |
| return pt() | return pt() |
| def manage_addECHO_locale(self,lang,title,label,text=None,content_type=None,RESPONSE=None): | |
| """add echo locale""" | |
| def changeECHO_resource(self,metalink,link,title,label,description,contentType,responsible,weight,viewClassification="",coords=None,credits=None,RESPONSE=None): | id="locale_"+lang |
| """Änderung der Properties""" | |
| self._setObject(id, ECHO_locale(id,lang,title,label,text,content_type)) | |
| if RESPONSE is not None: | |
| RESPONSE.redirect('manage_main') | |
| coordsnew=[ string.split(x,",") for x in coords] | |
| class ECHO_copyright(Folder,ECHO_basis): | |
| """Copyright informationen""" | |
| meta_type="ECHO_copyright" | |
| setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight,coordsnew) | |
| self.coords=coordsnew[0:] | |
| self.link=link | |
| self.metalink=metalink | |
| if RESPONSE is not None: | def __init__(self,id,title,copyrights): |
| RESPONSE.redirect('manage_main') | """init""" |
| self.title=title | |
| self.id=id | |
| self.copyrights=copyrights[0:] | |
| def getCopyrights(self): | |
| """return coyprights""" | |
| return self.copyrights | |
| manage_options = Folder.manage_options+( | manage_options = Folder.manage_options+( |
| {'label':'Main Config','action':'ECHO_resource_config'}, | {'label':'Main Config','action':'ECHO_copyright_configForm'}, |
| {'label':'Metadata','action':'ECHO_getResourceMD'}, | |
| {'label':'Graphics','action':'ECHO_graphicEntry'}, | |
| ) | ) |
| def getOverview(self): | |
| """overview graphics""" | |
| return self.aq_parent.ZopeFind(self.aq_parent,obj_ids=['overview'])[0][1] | def ECHO_copyright_configForm(self): |
| """change form""" | |
| pt=zptFile(self, 'zpt/ChangeECHO_copyright') | |
| pt.content_type="text/html" | |
| return pt() | |
| def ECHO_copyright_config(self,title,RESPONSE=None): | |
| """change""" | |
| self.title=title | |
| self.copyrights=[] | |
| self.copyrights=getCopyrightsFromForm(self,self.REQUEST.form)[0:] | |
| if RESPONSE is not None: | |
| RESPONSE.redirect('manage_main') | |
| def ECHO_graphicEntry(self): | def manage_addECHO_copyrightForm(self): |
| """DO nothing""" | """Form for adding""" |
| overview = self.aq_parent.ZopeFind(self.aq_parent,obj_ids=['overview']) | pt=zptFile(self, 'zpt/AddECHO_copyright.zpt') |
| if overview: | |
| pt=PageTemplateFile('Products/ECHO_content/zpt/ECHO_draw.zpt').__of__(self) | |
| return pt() | return pt() |
| else: | |
| return "NO OVERVIEW GRAPHICS" | |
| def ECHO_enterCoords(self,coordstr,angle="",RESPONSE=None): | def manage_addECHO_copyright(self, id,title,RESPONSE=None): |
| """Enter coords""" | """add the copyright""" |
| coords=self.coords | |
| temco=coordstr.split(",") | |
| temco.append(angle) | |
| coords.append(temco) | |
| self.coords=coords[0:] | meta_type="ECHO_copyright" |
| #first generate copyrights as list of tripels (mediaType,partner,copyrightType) | |
| self._setObject(id, ECHO_copyright(id, title,getCopyrightsFromForm(self,self.REQUEST.form))) | |
| if RESPONSE is not None: | if RESPONSE is not None: |
| RESPONSE.redirect('ECHO_graphicEntry') | RESPONSE.redirect('manage_main') |
| def ECHO_getResourceMD(self,template="yes"): | class ECHO_layoutTemplate(ZopePageTemplate,ECHO_basis): |
| """Einlesen der Metadaten und Anlegen dieser Metadaten als Informationen zur Resource""" | """Create a layout Template for different purposes""" |
| (metadict, error)=readMetadata(self.metalink) | |
| meta_type="ECHO_layoutTemplate" | |
| def __init__(self, id, text=None, content_type=None,EchoType=None): | |
| self.id = str(id) | |
| if not error=="": #Fehler beim Auslesen des Metafiles | self.ZBindings_edit(self._default_bindings) |
| return "ERROR:",error | if text is None: |
| for key in metadict.keys():#Hinzufügen der Felder | self._default_content_fn = os.path.join(package_home(globals()),'zpt','ECHO_%s_template_standard.zpt'%EchoType) |
| text = open(self._default_content_fn).read() | |
| if content_type is None: | |
| content_type = self.content_type | |
| self.pt_edit(text, content_type) | |
| def manage_addECHO_layoutTemplateForm(self): | |
| """Form for adding""" | |
| pt=zptFile(self, 'zpt/AddECHO_layoutTemplate.zpt') | |
| return pt() | |
| setattr(self,key,metadict[key].encode('ascii','replace')) | |
| def manage_addECHO_layoutTemplate(self, EchoType,title=None,REQUEST=None): | |
| "Add a Page Template with optional file content." | |
| if type(EchoType)==StringType: | |
| EchoTypes=[EchoType] | |
| else: | |
| EchoTypes=EchoType | |
| self.metadata=metadict.keys() | for singleType in EchoTypes: |
| self.label=self.generate_label() | id = str(singleType)+"_template" |
| if REQUEST is None: | |
| self._setObject(id, ECHO_layoutTemplate(id, text,EchoType=singleType)) | |
| 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_layoutTemplate(id,EchoType=singleType) | |
| else: | |
| zpt = ECHO_layoutTemplate(id, file, headers.get('content_type')) | |
| if template=="yes": | self._setObject(id, zpt) |
| pt=PageTemplateFile('Products/ECHO_content/zpt/ECHO_resourceMD.zpt').__of__(self) | ob = getattr(self, id) |
| return pt() | if title: |
| ob.pt_setTitle(title) | |
| try: | |
| u = self.DestinationURL() | |
| except AttributeError: | |
| u = REQUEST['URL1'] | |
| def ECHO_getMD(self,item): | |
| """Ausgabe der MD""" | |
| return getattr(self,item) | |
| def index_html(self): | REQUEST.RESPONSE.redirect(u+'/manage_main') |
| """standard page""" | return '' |
| return self.REQUEST.RESPONSE.redirect(self.link) | class ECHO_fullText(ZopePageTemplate,ECHO_basis,ECHO_language): |
| """echo fulltext in xml""" | |
| def generate_label(self): | meta_type="ECHO_fullText" |
| """Erzeugt_standard_Label aus Template""" | |
| pt=getattr(self,"label_template_"+self.bib_type) | |
| return pt() | |
| def manage_addECHO_resourceForm(self): | def getPage(self,nr='1'): |
| """Form for adding a ressource""" | """get page n""" |
| pt=PageTemplateFile('Products/ECHO_content/zpt/AddECHO_resourceForm.zpt').__of__(self) | #return self().encode('latin-1','ignore') |
| return pt() | try: |
| dom=xml.dom.minidom.parseString(self()) | |
| except: | |
| dom=xml.dom.minidom.parseString(self.utf8ify(self())) | |
| pages=dom.getElementsByTagName('page') | |
| return pages[int(nr)-1].toxml() | |
| # Product registration and Add support | |
| manage_addECHO_fullTextForm = PageTemplateFile( | |
| 'zpt/AddECHO_fullText.zpt', globals()) | |
| def manage_addECHO_fullText(self, id, title=None, text=None, | |
| REQUEST=None, submit=None): | |
| "Add a Page Template with optional file content." | |
| def manage_addECHO_resource(self,id,title,label,description,contentType,responsible,link,metalink,weight,credits=None,coords=None,RESPONSE=None): | id = str(id) |
| """addaresource""" | 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')) | |
| newObj=ECHO_resource(id,link,metalink,title,label,description,contentType,responsible,credits,weight,coords) | self._setObject(id, zpt) |
| self._setObject(id,newObj) | try: |
| u = self.DestinationURL() | |
| except AttributeError: | |
| u = REQUEST['URL1'] | |
| if submit == " Add and Edit ": | |
| u = "%s/%s" % (u, urllib.quote(id)) | |
| REQUEST.RESPONSE.redirect(u+'/manage_main') | |
| return '' | |
| if RESPONSE is not None: | |
| 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' |
| security.declarePublic('content_html') | |
| def content_html(self): | |
| """template fuer content""" | |
| ret= ECHO_basis.content_html(self,'externalLink') | |
| if type(ret) is StringType: | |
| return ret.decode('utf-8') | |
| else: | |
| return ret | |
| def __init__(self,id,link,title,label,description,contentType,responsible,credits,weight,coords): | |
| def __init__(self,id,link,title,label,description,contentType,responsible,credits,weight,coords,linkType): | |
| self.id = id | self.id = id |
| """Festlegen der ID""" | """Festlegen der ID""" |
| Line 360 class ECHO_externalLink(Folder): | Line 456 class ECHO_externalLink(Folder): |
| self.responsible=responsible | self.responsible=responsible |
| coordsnew=[ string.split(x,",") for x in coords] | coordsnew=[ string.split(x,",") for x in coords] |
| self.coords=coordsnew | self.coords=coordsnew |
| self.linkType = linkType # Linktypen 'otherPresentation','external' | |
| def ECHO_externalLink_config(self): | def ECHO_externalLink_config(self): |
| """Main configuration""" | """Main configuration""" |
| Line 369 class ECHO_externalLink(Folder): | Line 467 class ECHO_externalLink(Folder): |
| if not hasattr(self,'coords'): | if not hasattr(self,'coords'): |
| self.coords=[''] | self.coords=[''] |
| #print "G",self.coords | |
| pt=PageTemplateFile('Products/ECHO_content/zpt/ChangeECHO_externalLink.zpt').__of__(self) | |
| return pt() | |
| def changeECHO_externalLink(self,link,title,label,description,contentType,responsible,weight,coords=None,credits=None,RESPONSE=None): | pt=zptFile(self, 'zpt/ChangeECHO_externalLink.zpt') |
| return pt() | |
| """Änderung der Properties""" | |
| coordsnew=[ string.split(x,",") for x in coords] | |
| setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight,coords) | def changeECHO_externalLink(self,link,title,label,description,contentType,responsible,weight,coords=None,credits=None,RESPONSE=None,linkType='otherPresentation'): |
| """Aenderung der Properties""" | |
| setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight) | |
| self.coords=coordsnew[0:] | |
| self.link=link | self.link=link |
| self.linkType = linkType | |
| if RESPONSE is not None: | if RESPONSE is not None: |
| RESPONSE.redirect('manage_main') | RESPONSE.redirect('manage_main') |
| def getLinkType(self): | |
| """ return linkType """ | |
| if hasattr(self,"linkType"): | |
| return self.linkType | |
| else : | |
| return 'otherPresentation' | |
| manage_options = Folder.manage_options+( | def setLinkType(self,type): |
| """ set linkType """ | |
| self.linkType = type | |
| def checkLink(self): | |
| """ returns tuple (isWorking,Error) """ | |
| try: | |
| urllib2.urlopen(self.link) | |
| return (True, '') | |
| except urllib2.HTTPError, e: | |
| return (False, e.code) | |
| except urllib2.URLError, e: | |
| return (False, str(e.reason)) | |
| except: | |
| return (False, 'unknown Error') | |
| manage_options = ( | |
| {'label':'Main Config','action':'ECHO_externalLink_config'}, | {'label':'Main Config','action':'ECHO_externalLink_config'}, |
| ) | {'label':'Graphic Coords','action':'ECHO_graphicEntry'}, |
| )+Folder.manage_options | |
| def getCredits(self): | |
| """Ausgabe der credits""" | |
| if self.credits: | |
| return self.credits | |
| else: | |
| return [] | |
| def index_html(self): | def index_html(self): |
| """standard page""" | """standard page""" |
| return self.REQUEST.RESPONSE.redirect(self.link) | return self.REQUEST.RESPONSE.redirect(self.link) |
| def manage_addECHO_externalLinkForm(self): | def manage_addECHO_externalLinkForm(self): |
| """Form for external Links""" | """Form for external Links""" |
| pt=PageTemplateFile('Products/ECHO_content/zpt/AddECHO_externalLinkForm.zpt').__of__(self) | pt=zptFile(self, 'zpt/AddECHO_externalLinkForm.zpt') |
| return pt() | return pt() |
| def manage_addECHO_externalLink(self,id,title,label,description,contentType,responsible,link,weight,coords=None,credits=None,RESPONSE=None): | def manage_addECHO_externalLink(self,id,title,label,description,contentType,responsible,link,weight,coords=None,credits=None,RESPONSE=None,linkType='otherPresentation'): |
| """Add an external Link""" | """Add an external Link""" |
| newObj=ECHO_externalLink(id,link,title,label,description,contentType,responsible,credits,weight,coords) | newObj=ECHO_externalLink(id,link,title,label,description,contentType,responsible,credits,weight,coords,linkType) |
| self._setObject(id,newObj) | self._setObject(id,newObj) |
| Line 421 def manage_addECHO_externalLink(self,id, | Line 535 def manage_addECHO_externalLink(self,id, |
| RESPONSE.redirect('manage_main') | RESPONSE.redirect('manage_main') |
| class ECHO_link(ECHO_externalLink): | |
| """external_link""" | |
| meta_type="ECHO_link" | |
| manage_options = ECHO_externalLink.manage_options+( | |
| {'label':'add links config','action':'ECHO_link_addLinksForm'}, | |
| ) | |
| def ECHO_link_addLinksForm(self): | |
| """Main configuration""" | |
| pt=zptFile(self, 'zpt/ChangeECHO_link_addLinks.zpt') | |
| return pt() | |
| def ECHO_link_addLinks(self,addLinks,RESPONSE): | |
| """add links""" | |
| self.addLinks=addLinks | |
| if RESPONSE is not None: | |
| RESPONSE.redirect('manage_main') | |
| def content_html(self): | |
| """template fuer link""" | |
| if hasattr(self,"link_template"): | |
| ret=ECHO_basis.content_html(self,'link') | |
| else: | |
| ret=ECHO_basis.content_html(self,'collection') | |
| #return ret | |
| return ret | |
| # | |
| # | |
| # try: | |
| # return ret.decode('utf-8') | |
| # except: | |
| # try: | |
| # return ret.decode('latin-1') | |
| # except: | |
| # | |
| # return ret | |
| # | |
| def getCopyrightsHTML(self): | |
| """gib (link auf copyright link, mediatyp, institution, copyrightType, label von copyrightType) aus""" | |
| if hasattr(self,'copyrightModel'): | |
| obj=self.copyrightModel | |
| else: | |
| return "ERROR" | |
| ret=[] | |
| for copyright in obj.getCopyrights(): #copyright - media / partner / copyrightID | |
| try: | |
| if hasattr(self.copyrightTypes,copyright[2]): | |
| copyrightTypeObj=getattr(self.copyrightTypes,copyright[2]) | |
| link="copyrightTypes/"+copyright[2]+'/copyright.html' | |
| else: | |
| copyrightTypeObj=getattr(obj,copyright[2]) | |
| link="copyrightModel/"+copyright[2]+'/copyright.html' | |
| label=copyrightTypeObj.label | |
| url=getattr(copyrightTypeObj, 'url', '') | |
| if url!='': | |
| ret.append((url,copyright[0],copyright[1],copyright[2],label)) | |
| else: | |
| if hasattr(copyrightTypeObj, 'copyright.html'): | |
| ret.append(("""%s?partner=%s"""%(link,copyright[1]),copyright[0],copyright[1],copyright[2],label)) | |
| else: | |
| ret.append(('empty',copyright[0],copyright[1],copyright[2],label)) | |
| except: | |
| """nothing""" | |
| return ret | |
| def getInstitutionsHTML(self): | |
| """gibt Liste der foerdernden Institutionen aus""" | |
| if hasattr(self,'support'): | |
| obj=self.support | |
| ret=obj.getSupporter() | |
| return ret | |
| else: | |
| return '' | |
| def getOwnerOriginalsHTML(self): | |
| """gibt Liste der foerdernden Institutionen aus""" | |
| if hasattr(self,'ownerOriginal'): | |
| obj=self.ownerOriginal | |
| ret=obj.getOwner() | |
| return ret | |
| else: | |
| return '' | |
| def getDigiCopyByHTML(self): | |
| """gibt Liste der foerdernden Institutionen aus""" | |
| if hasattr(self,'digiCopyBy'): | |
| obj=self.digiCopyBy | |
| ret=obj.getDigiCopyBy() | |
| return ret | |
| else: | |
| return '' | |
| def index_html(self): | |
| """standard link""" | |
| if self.link: | |
| splitted=self.link.split("?") | |
| if len(splitted)>1: | |
| params=cgi.parse_qs(splitted[1]) | |
| for x in params.keys(): | |
| if type(params[x]) is ListType: | |
| params[x]=params[x][0] | |
| class ECHO_collection(Folder, Persistent, Implicit): | |
| else: | |
| params={} | |
| if getattr(self,'addLinks','yes')=="yes": | |
| params['backLink']=self.aq_parent.absolute_url() | |
| params['startLink']=splitted[0]+"?"+urllib.urlencode(params) | |
| return self.REQUEST.RESPONSE.redirect(splitted[0]+"?"+urllib.urlencode(params)) | |
| else: | |
| return "" | |
| def manage_addECHO_linkForm(self): | |
| """Form for external Links""" | |
| pt=zptFile(self, 'zpt/AddECHO_linkForm.zpt') | |
| return pt() | |
| def manage_addECHO_link(self,id,title,label,description="",contentType="",responsible="",link="",weight="",coords=[],credits=None,linkType="external",RESPONSE=None): | |
| """Add an external Link""" | |
| newObj=ECHO_link(id,link,title,label,description,contentType,responsible,credits,weight,coords,linkType) | |
| self._setObject(id,newObj) | |
| getattr(self,id).addLinks='no' | |
| if RESPONSE is not None: | |
| RESPONSE.redirect('manage_main') | |
| class ECHO_collection(CatalogAware, Folder, Persistent, Implicit, Cacheable,ECHO_basis): | |
| """ECHO Collection""" | """ECHO Collection""" |
| management_page_charset="utf-8" | |
| security=ClassSecurityInfo() | security=ClassSecurityInfo() |
| meta_type='ECHO_collection' | meta_type='ECHO_collection' |
| default_catalog='resourceCatalog' | |
| rootMetaTypes = ['ECHO_root', 'ECHO_main', 'ECHO_nav'] | |
| # viewClassificationList=viewClassificationListMaster | |
| displayTypes=displayTypes | |
| path="/mpiwg/online/permanent/shipbuilding" | |
| def getSection(self, crumbs=None): | |
| """returns the current section name""" | |
| # use breadcrumbs if available | |
| if crumbs is not None and len(crumbs) > 0: | |
| return crumbs[0][2].getId() | |
| p = self | |
| sec = None | |
| # descend parents to the root (and remember the last id) | |
| while p is not None and p.meta_type not in self.rootMetaTypes: | |
| sec = p.getId() | |
| p = aq_parent(p.context) | |
| return sec | |
| def getSubSection(self, crumbs=None): | |
| """returns the current subsection name""" | |
| # use breadcrumbs if available | |
| if crumbs is not None and len(crumbs) > 1: | |
| return crumbs[1][2].getId() | |
| p = self | |
| sec = None | |
| subsec = None | |
| # descend parents to the root (and remember the last id) | |
| while p is not None and p.meta_type not in self.rootMetaTypes: | |
| subsec = sec | |
| sec = p.getId() | |
| p = aq_parent(p.context) | |
| return subsec | |
| def getCrumb(self): | |
| """returns breadcrumb for this object""" | |
| return ECHO_helpers.getCrumb(self) | |
| def getHierCrumbs(self): | |
| """returns a list of hierarchical breadcrumbs from self to the ECHO_root""" | |
| return ECHO_helpers.getHierCrumbs(self) | |
| def exportImportObjects_html(self,RESPONSE): | |
| """ImportObject""" | |
| pt=zptFile(self, 'zpt/exportImportObjects.zpt') | |
| pt.content_type="text/html" | |
| return pt() | |
| def importObjects_html(self,RESPONSE): | |
| """ImportObject""" | |
| pt=zptFile(self, 'zpt/importObjects.zpt') | |
| pt.content_type="text/html" | |
| return pt() | |
| def importObjects(self,zfile,RESPONSE=None,REQUEST=None): | |
| """import object from file""" | |
| zf=zipfile.ZipFile(zfile,"r") | |
| tmpdir=tempfile.mkdtemp() # create tempdir | |
| ret=None | |
| for name in zf.namelist(): | |
| ds,fn=tempfile.mkstemp() | |
| tf=file(fn,"w") | |
| x=zf.read(name) | |
| tf.write(x) | |
| tf.close() | |
| try: | |
| self._importObjectFromFile(fn,set_owner=1) | |
| except: | |
| if not ret: | |
| ret="" | |
| ret+="Cannot import: %s (Already existing?)<br>"%name | |
| os.close(ds) | |
| os.remove(fn) | |
| zf.close() | |
| if ret: | |
| return """<html><body>%s</body></html>"""%ret | |
| if RESPONSE: | |
| RESPONSE.redirect(self.absolute_url()) | |
| def exportObjects_html(self,RESPONSE): | |
| """Export objects""" | |
| pt=zptFile(self, 'zpt/exportObjects.zpt') | |
| pt.content_type="text/html" | |
| return pt() | |
| def exportObjects(self,ids,RESPONSE=None): | |
| """export objects with type id""" | |
| if not (type(ids) is ListType): | |
| ids=[ids] | |
| tmpdir=tempfile.mkdtemp() # create tempdir | |
| objs=self.ZopeFind(self,obj_ids=ids) | |
| tmpfile=tempfile.mkstemp()[1] | |
| zf=zipfile.ZipFile(tmpfile,"w") | |
| for obj in objs: | |
| f = os.path.join(tmpdir, '%s.zexp' %obj[0]) | |
| #print E.absolute_url() | |
| obj[1]._p_jar.exportFile(obj[1]._p_oid, f) | |
| zf.write(f,obj[0]) | |
| zf.close() | |
| shutil.rmtree(tmpdir) | |
| if RESPONSE: | |
| RESPONSE.setHeader("Content-Type","application/octet-stream") | |
| len=os.stat(tmpfile)[6] | |
| RESPONSE.setHeader("Content-Length",len) | |
| RESPONSE.setHeader("Content-Disposition","""attachement; filename=%s"""%"export.zip") | |
| fh=file(tmpfile) | |
| for x in fh.read(): | |
| RESPONSE.write(x) | |
| fh.close() | |
| def getMDValueSimpleSearchField(self): | |
| """returns value for simple search""" | |
| return " ".join([self.title,self.description]) | |
| def getTitleAndLabel(self): | |
| """gibt title und label zurueck""" | |
| return (getattr(self,'title',''),getattr(self,'label','')) | |
| def localizeObjects(self): | |
| """localize all objects""" | |
| contents=self.ZopeFind(self,obj_metatypes=['ECHO_externalLink','ECHO_link','ECHO_mapText']) | |
| find=self.ZopeFind(self,obj_ids=('locale_en')) | |
| if not find: | |
| self.manage_addECHO_locale("en",'','') | |
| for content in contents: | |
| if content[1].meta_type in ['ECHO_link','ECHO_externalLink']: | |
| find=content[1].ZopeFind(content[1],obj_metatypes=('ECHO_mapText')) | |
| if find: | |
| root=find[0][1] | |
| locale=find[0][1].ZopeFind(find[0][1],obj_ids=('locale_en')) | |
| else: | |
| root=None | |
| else: | |
| root=content[1] | |
| locale=content[1].ZopeFind(content[1],obj_ids=('locale_en')) | |
| if root and not locale: | |
| root.manage_addECHO_locale("en",'','') | |
| pt=zptFile(self, 'zpt/localizeObjects.zpt') | |
| return pt() | |
| def localize(self,REQUEST,RESPONSE): | |
| """localize""" | |
| for key in REQUEST.form.keys(): | |
| splitted=key.split("!") | |
| if splitted[0]=="" or splitted[0]=="en" or splitted[0]=="title" or splitted[0]=="label": | |
| if splitted[0]=="en": | |
| setattr(self.locale_en,splitted[1],REQUEST.form[key]) | |
| else: | |
| setattr(self,splitted[0],REQUEST.form[key]) | |
| else: | |
| obj=getattr(self,splitted[0]) | |
| if obj.meta_type=="ECHO_mapText": | |
| if splitted[1]=="en": | |
| obj.locale_en.pt_edit(REQUEST.form[key],obj.locale_en.content_type) | |
| else: | |
| obj.pt_edit(REQUEST.form[key],obj.content_type) | |
| else: | |
| text=obj.ZopeFind(obj,obj_metatypes=['ECHO_mapText']) | |
| if splitted[1]=="en": | |
| text[0][1].locale_en.pt_edit(REQUEST.form[key],text[0][1].locale_en.content_type) | |
| else: | |
| text[0][1].pt_edit(REQUEST.form[key],text[0][1].content_type) | |
| if RESPONSE is not None: | |
| RESPONSE.redirect('manage_main') | |
| 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: | |
| try: | |
| ret+=content[1].getRDF()+"\n" | |
| except: | |
| logging.error("getrdf: "+repr(content[1].getRDF())) | |
| try: | |
| ret+=self.unicodify(content[1].getRDF())+"\n" | |
| except: | |
| logging.error("--still cannot do it") | |
| ret+=repr(content[1].getRDF())+"\n" | |
| ret+="""<rdf:Seq rdf:about="%s">\n"""%urn | |
| for content in contents: | |
| nurn=content[1].absolute_url() | |
| ret+=li%nurn | |
| return ret+"</rdf:Seq>" | |
| def changeLabels(self): | |
| """change form""" | |
| pt=zptFile(self, 'zpt/changeLabelsForm') | |
| pt.content_type="text/html" | |
| return pt() | |
| def changeTitles(self): | |
| """change form""" | |
| pt=zptFile(self, 'zpt/changeTitleForm') | |
| pt.content_type="text/html" | |
| return pt() | |
| def changeWeights(self): | |
| """change form""" | |
| pt=zptFile(self, 'zpt/changeWeightForm') | |
| pt.content_type="text/html" | |
| return pt() | |
| def changeMetaDataLinks(self): | |
| """change form""" | |
| pt=zptFile(self, 'zpt/changeMetaDataLinkForm') | |
| pt.content_type="text/html" | |
| return pt() | |
| def changeAccessRightsCollectionForm(self,preselect=None): | |
| """change access rights of all resources in this collection""" | |
| pt=zptFile(self, 'zpt/changeAccessRightsCollectionForm') | |
| pt.content_type="text/html" | |
| return pt(preselect=preselect) | |
| def changeAccessRightsCollection(self): | |
| """change""" | |
| ret="" | |
| argv=self.REQUEST.form | |
| resources=self.ZopeFind(self,obj_metatypes=['ECHO_resource']) | |
| for resource in resources: | |
| if argv.has_key(resource[1].getId()+'_xml'): | |
| ret+=resource[1].getId()+" "+argv[resource[1].getId()+'_xml']+"</br>" | |
| resource[1].setAccessRightXML(argv[resource[1].getId()+'_xml']) | |
| resource[1].accessRight=argv[resource[1].getId()+'_xml'] | |
| elif argv.has_key(resource[1].getId()+'_echo'): | |
| ret+="only local:"+resource[1].getId()+" "+argv[resource[1].getId()+'_echo']+"</br>" | |
| resource[1].accessRight=argv[resource[1].getId()+'_echo'] | |
| else: | |
| ret+="ERROR:" +resource[0] | |
| 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: | |
| pass | |
| 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: | |
| pass | |
| 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_movie','ECHO_resource','ECHO_collection','ECHO_link','ECHO_externalLink']) | |
| for resource in resources: | |
| try: | |
| ret+=resource[1].getId()+" "+argv[resource[1].getId()]+"</br>" | |
| resource[1].weight=argv[resource[1].getId()][0:] | |
| except: | |
| pass | |
| return ret | |
| def changeTitlesInCollection(self): | |
| """change all lables of a collection""" | |
| ret="" | |
| argv=self.REQUEST.form | |
| resources=self.ZopeFind(self,obj_metatypes=['ECHO_pageTemplate','ECHO_movie','ECHO_resource','ECHO_collection','ECHO_link','ECHO_externalLink']) | |
| for resource in resources: | |
| try: | |
| ret+=resource[1].getId()+" "+argv[resource[1].getId()]+"</br>" | |
| resource[1].title=argv[resource[1].getId()][0:] | |
| except: | |
| pass | |
| return ret | |
| def changeLabelsInCollection(self): | |
| """change all lables of a collection""" | |
| ret="" | |
| argv=self.REQUEST.form | |
| resources=self.ZopeFind(self,obj_metatypes=['ECHO_pageTemplate','ECHO_movie','ECHO_resource','ECHO_collection','ECHO_link','ECHO_externalLink']) | |
| for resource in resources: | |
| try: | |
| ret+=resource[1].getId()+" "+argv[resource[1].getId()]+"</br>" | |
| resource[1].label=argv[resource[1].getId()][0:] | |
| except: | |
| pass | |
| return ret | |
| def importCollection(self,path=None,viewerUrl=None,metaDataUrl=None,replacePathPermanent=None,replacePathExperimental=None,RESPONSE=None): | |
| """liest verzeichnisse aus dem pfad und legt sie dann als objekte in den ordner""" | |
| if path is None: | |
| pt=zptFile(self, 'zpt/importCollection.zpt') | |
| return pt() | |
| files=os.listdir(path) | |
| ret="" | |
| for fileName in files: | |
| if fileName: | |
| if (replacePathExperimental and replacePathExperimental!=''): | |
| path=re.sub(replacePathExperimental,"/mpiwg/online/experimental",path) | |
| if (replacePathPermanent and replacePathPermanent!=''): | |
| path=re.sub(replacePathPermanent,"/mpiwg/online/permanent",path) | |
| link=viewerUrl%(path+"/"+fileName+"/pageimg") | |
| metalink=metaDataUrl+"/"+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,'','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 changeViewerForm(self): | |
| """change the viewer template set""" | |
| pt=zptFile(self, 'zpt/changeECHOViewer') | |
| return pt() | |
| def getTextToolsField(self,name,default=''): | |
| """Lese text tool field der Collection not implemented yet!""" | |
| return default | |
| def changeViewer(self,newViewer,REQUEST=None,RESPONSE=None): | |
| """changes all ressources to the newViewer""" | |
| resources=self.ZopeFind(self,obj_metatypes=['ECHO_resource'],search_sub=1) | |
| if RESPONSE is not None: | |
| RESPONSE.write("<html><body>") | |
| for resource in resources: | |
| done,msg=resource[1].changeViewer(newViewer) | |
| if done: | |
| if RESPONSE is not None: | |
| RESPONSE.write("<p>OK: %s"%resource[0]) | |
| else: | |
| if RESPONSE is not None: | |
| RESPONSE.write("<p><a href='%s'>ERROR: %s (%s)</a>"%(resource[1].absolute_url()+'/ECHO_resource_config_main',resource[0],msg)) | |
| if RESPONSE is not None: | |
| RESPONSE.write("<p>Done</p></body></html>") | |
| def 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) | |
| #logger("ECHO (copyTitleToInfoXMLFolder)",logging.INFO,txt) | |
| if RESPONSE is not None: | |
| RESPONSE.write("done!\n") | |
| RESPONSE.close() | |
| RESPONSE.redirect('manage_main') | |
| def copySearchFields(self,RESPONSE=None): | |
| """copys < metadatafields to the object""" | |
| resources=self.ZopeFind(self,obj_metatypes=['ECHO_resource'],search_sub=1) | |
| for resource in resources: | |
| resource[1].copySearchFields() | |
| if RESPONSE is not None: | |
| RESPONSE.redirect('manage_main') | |
| def getPartnerCopyright(self,name,sonst="generic"): | |
| """gibt generisches copyright eines partners aus, sonst behalte jetzige einsteillung""" | |
| #print "hi",name,sonst | |
| #print getattr(self.partners,name).copyrightType | |
| try: | |
| partner=getattr(self.partners,name) | |
| return partner.copyrightType | |
| except: | |
| print "error" | |
| return sonst | |
| def partnerSelector_HTML(self,selected=None): | |
| """give type selector""" | |
| if not selected: | |
| retStr="<option selected>\n" | |
| else: | |
| retStr="<option>\n" | |
| try: # erste version copyrightTypes exists | |
| for partner in self.getPartners(): | |
| partnerTitle = partner.title | |
| partnerId = partner.__name__ | |
| if selected and (partnerId==selected): | |
| retStr+="""<option selected value="%s">%s\n"""%(partnerId,partnerTitle) | |
| else: | |
| retStr+="""<option value="%s">%s\n"""%(partnerId,partnerTitle) | |
| except: | |
| """nothing""" | |
| return retStr | |
| # def getViewClassification(self): | |
| # if hasattr(self,'viewClassification'): | |
| # return self.viewClassification | |
| # else: | |
| # return "" | |
| def createRessourcesFromXMLForm(self): | |
| """form""" | |
| pt=zptFile(self, 'zpt/createRessourcesFromXMLForm.zpt') | |
| return pt() | |
| def createRessourcesFromXML(self,fileupload): | |
| """read an XML file for generating resources""" | |
| dom=xml.dom.minidom.parse(fileupload) | |
| ret="<h2>Added</h2>" | |
| for resource in dom.getElementsByTagName('resource'): | |
| link=getText(resource.getElementsByTagName('link')[0].childNodes) | |
| label=getText(resource.getElementsByTagName('label')[0].childNodes) | |
| pageimglink=getText(resource.getElementsByTagName('pageimglink')[0].childNodes) | |
| #splitted=link.split("?")[0].split("/") | |
| #id=splitted[len(splitted)-1].encode('ascii') | |
| id=re.sub(" ","_",label).encode('ascii') | |
| ret+="<p>"+label+"</p>" | |
| manage_addECHO_resource(self,id,label.encode('ascii'),label.encode('ascii'),"","",pageimglink.encode('ascii'),link.encode('ascii'),"","") | |
| return ret | |
| security.declarePublic('getImageTag') | |
| def getImageTag(self): | def getImageTag(self): |
| """GetTag""" | """GetTag""" |
| try: | try: |
| Line 434 class ECHO_collection(Folder, Persistent | Line 1226 class ECHO_collection(Folder, Persistent |
| except: | except: |
| return "" | return "" |
| def addMovie(self,id,title,label,description,contentType,responsible,link,thumbUrl,rawFile,lowresFile,metalink,weight,credits=None,coords=None,RESPONSE=None): | |
| """SSS""" | |
| #manage_addECHO_movie(self,id,title,label,description,responsible,link,thumbUrl,rawFile,metalink,weight,credits=None,coords=None,RESPONSE=None) | |
| if not hasattr(self,id): | |
| try: | |
| manage_addECHO_movie(self,id,title,label,description,responsible,link,thumbUrl,rawFile,lowresFile,metalink,weight,credits=None,coords=None,RESPONSE=None) | |
| return "done" | |
| except: | |
| return None | |
| else: | |
| obj=getattr(self,id) | |
| obj.changeECHO_movie_main(metalink,link,rawFile,lowresFile,thumbUrl,title,label,description,contentType,weight=weight) | |
| return "changed" | |
| def addResource(self,id,title,label,description,contentType,responsible,link,metalink,weight,credits=None,coords=None,RESPONSE=None): | def addResource(self,id,title,label,description,contentType,responsible,link,metalink,weight,credits=None,coords=None,RESPONSE=None): |
| """SSS""" | """SSS""" |
| try: | try: |
| manage_addECHO_resource(self,id,title,label,description,contentType,responsible,link,metalink,weight,credits=None,coords=None,RESPONSE=None) | manage_addECHO_resource(self,id,title,label,description,responsible,link,metalink,weight,credits=None,coords=None,RESPONSE=None) |
| return "done" | return "done" |
| except: | except: |
| logging.error("ECHOcollection: (AddResource): %s %s"%sys.exc_info()[0:2]) | |
| return None | |
| def addResourceAndCreateLabelAndTitle(self,id,title,label,description,contentType,responsible,link,metalink,weight,credits=None,coords=None,RESPONSE=None): | |
| """SSS""" | |
| ret = self.addResource(id,title,label,description,contentType,responsible,link,metalink,weight,credits,coords,RESPONSE) | |
| if ret is None: | |
| return None | |
| try: | |
| server2=getattr(self,id) | |
| server2.copyIndex_meta2echo_resource() | |
| server2.generate_label() | |
| server2.generate_title() | |
| except: | |
| logging.error("An Error occured adding the resource A\n %s %s"%sys.exc_info()[0:2]) | |
| return None | return None |
| return "done" | |
| def getSecondaryLink(self): | |
| """secondary link""" | |
| try: | |
| return self.secondaryLink | |
| except: | |
| return "" | |
| def getCollectionTreeXML(self): | def getSecondaryLinkTitle(self): |
| """secondary link""" | |
| try: | |
| return self.secondaryLinkTitle | |
| except: | |
| return "" | |
| def getCollectionTreeXML(self,pwstr=None): | |
| """Tree as XML""" | """Tree as XML""" |
| def getCollection(object,depth=0): | def addPassWd(str,pwstr=None): |
| """adds a user/passwd to an url""" | |
| if pwstr: | |
| txt2=re.sub(r"(http://)(.*?)","\g<1>%s@\g<2>"%pwstr,str) | |
| else: | |
| txt2=re.sub(r"(http://)(.*?)","\g<1>www:3333@\g<2>",str) | |
| return txt2 | |
| def getCollection(object,depth=0,pwstr=None): | |
| depth+=1 | depth+=1 |
| collections="" | collections="" |
| for entry in object.__dict__.keys(): | for entry in object.__dict__.keys(): |
| element=getattr(object,entry) | element=getattr(object,entry) |
| try: | try: |
| if element.meta_type=="ECHO_collection": | if element.meta_type in ["ECHO_collection","ECHO_group"]: |
| collections+="<element name=\""+element.title+"\" url=\""+element.absolute_url()+"\">" | collections+="<element name=\""+urllib.quote(element.title)+"\" url=\""+addPassWd(element.absolute_url(),pwstr=pwstr)+"\">" |
| collections+=getCollection(element,depth)+"</element>\n" | collections+=getCollection(element,depth)+"</element>\n" |
| except: | except: |
| """nothing""" | """nothing""" |
| return collections | return collections |
| ret="""<?xml version="1.0" encoding="utf-8" ?>""" | |
| return ret+"<collection>"+getCollection(self,pwstr=pwstr)+"</collection>" | |
| return "<collection>"+getCollection(self)+"</collection>" | def createAllJSAreas(self,mapColTypes=None): |
| """create area calls for JavaScript""" | |
| areas = self.getAllMapAreas(mapColTypes=mapColTypes) | |
| return self.createJSAreas(areas) | |
| def createJavaScript(self): | |
| """CreateJava""" | emptyPartner=ECHO_partner("", "","", "", "", "", "", "", "") |
| ret=javaScriptMain | |
| dynamical="" | |
| for ob in self.getGraphicCoords(): | |
| dynamical+="""Coords.push(new Coord('%s', Img, %s));\n"""%(ob[1],ob[0]) | |
| ret+=javaHandler%dynamical | |
| return ret | |
| security.declarePublic('getCreditObject') | security.declarePublic('getCreditObject') |
| def getCreditObject(self,name): | def getCreditObject(self,name): |
| Line 477 class ECHO_collection(Folder, Persistent | Line 1322 class ECHO_collection(Folder, Persistent |
| try: | try: |
| return getattr(self.partners,name) | return getattr(self.partners,name) |
| except: | except: |
| return "" | |
| return self.emptyPartner | |
| security.declarePublic('ECHO_generateNavBar') | security.declarePublic('ECHO_generateNavBar') |
| def ECHO_generateNavBar(self): | def ECHO_generateNavBar(self): |
| Line 498 class ECHO_collection(Folder, Persistent | Line 1345 class ECHO_collection(Folder, Persistent |
| ret.append((label,link)) | ret.append((label,link)) |
| return ret | return ret |
| security.declarePublic('ECHO_rerenderLinksMD') | |
| def ECHO_rerenderLinksMD(self): | |
| """Rerender all Links""" | |
| for entry in self.__dict__.keys(): | |
| object=getattr(self,entry) | |
| try: | |
| if object.meta_type == 'ECHO_resource': | def ECHO_rerenderLinksMDWarning(self): |
| """change form""" | |
| object.ECHO_getResourceMD(template="no") | pt=zptFile(self, 'zpt/rerenderLinksWarning') |
| pt.content_type="text/html" | |
| except: | return pt() |
| """nothing""" | |
| return "Rerenderd all links to resources in: "+self.title | |
| security.declarePublic('ECHO_newViewerLink') | |
| def getCoords(self): | |
| try: | |
| x= [string.join(x,",") for x in self.coords] | security.declarePublic('ECHO_rerenderLinksMD') |
| return x | def ECHO_rerenderLinksMD(self,obj=None,types=['title','label']): |
| """Rerender all Links""" | |
| return ECHO_rerenderLinksMD(self,obj,types) | |
| except: | |
| return [] | def __init__(self,id,title,label,description="",contentType="",responsible="",credits="",weight="",sortfield="",coords=[],secondaryLinkTitle="",secondaryLink="",imageTag="",bgcolour="",isVisible=True): |
| def __init__(self,id,title,label,description,contentType,responsible,credits,weight,sortfield,coords,imageTag=""): | |
| #print "CO",coords | |
| self.id = id | self.id = id |
| """Festlegen der ID""" | """Festlegen der ID""" |
| Line 546 class ECHO_collection(Folder, Persistent | Line 1375 class ECHO_collection(Folder, Persistent |
| self.sortfield=sortfield | self.sortfield=sortfield |
| coordsnew=[ string.split(x,",") for x in coords] | coordsnew=[ string.split(x,",") for x in coords] |
| self.coords=coordsnew | self.coords=coordsnew |
| self.secondaryLinkTitle=secondaryLinkTitle | |
| self.secondaryLink=secondaryLink | |
| self.bgcolour=bgcolour | |
| self.isVisible=isVisible | |
| 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':'Graphics','action':'ECHO_graphicEntry'}, | {'label':'Change Titles','action':'changeTitles'}, |
| {'label':'Localize','action':'localizeObjects'}, | |
| {'label':'Change Weights','action':'changeWeights'}, | |
| {'label':'Rerender Labels and Titles','action':'ECHO_rerenderLinksMDWarning'}, | |
| {'label':'Export/Import Objects','action':'exportImportObjects_html'}, | |
| {'label':'Graphic Coords','action':'ECHO_graphicEntry'}, | |
| {'label':'create resources from XML','action':'createRessourcesFromXMLForm'}, | |
| {'label':'Change Image Viewer','action':'changeViewerForm'}, | |
| {'label':'ImportCollection','action':'importCollection'}, | |
| {'label':'Change access rights', 'action':'changeAccessRightsCollectionForm'}, | |
| ) | ) |
| def getOverview(self): | |
| """overview graphics""" | |
| return self.aq_parent.ZopeFind(self.aq_parent,obj_ids=['overview'])[0][1] | |
| def ECHO_graphicEntry(self): | |
| """DO nothing""" | |
| overview = self.aq_parent.ZopeFind(self.aq_parent,obj_ids=['overview']) | |
| if overview: | |
| pt=PageTemplateFile('Products/ECHO_content/zpt/ECHO_draw.zpt').__of__(self) | |
| return pt() | |
| else: | |
| return "NO OVERVIEW GRAPHICS" | |
| def ECHO_enterCoords(self,coordstr,angle="",RESPONSE=None): | |
| """Enter coords""" | |
| coords=self.coords | |
| temco=coordstr.split(",") | |
| temco.append(angle) | |
| coords.append(temco) | |
| self.coords=coords[0:] | |
| if RESPONSE is not None: | |
| RESPONSE.redirect('ECHO_graphicEntry') | |
| security.declarePublic('ECHO_collection_config') | security.declarePublic('ECHO_collection_config') |
| def ECHO_collection_config(self): | def ECHO_collection_config(self): |
| Line 594 class ECHO_collection(Folder, Persistent | Line 1407 class ECHO_collection(Folder, Persistent |
| if not hasattr(self,'sortfield'): | if not hasattr(self,'sortfield'): |
| self.sortfield="weight" | self.sortfield="weight" |
| if not hasattr(self,'coords'): | pt=zptFile(self, 'zpt/ChangeECHO_collection.zpt') |
| self.coords=[] | |
| pt=PageTemplateFile('Products/ECHO_content/zpt/ChangeECHO_collection.zpt').__of__(self) | |
| return pt() | return pt() |
| security.declarePublic('changeECHO_collection') | def getBgcolour(self): |
| """colour""" | |
| if hasattr(self,'bgcolour') and not (self.bgcolour==""): | |
| return self.bgcolour | |
| else: | |
| return "#dddddd" | |
| def changeECHO_collection(self,title,label,description,contentType,responsible,weight,credits=None,sortfield="weight",coords=None,RESPONSE=None,imageTag=""): | security.declarePublic('changeECHO_collection') |
| """Änderung der Properties""" | def changeECHO_collection(self,title,label,description,contentType,responsible,weight,secondaryLink,secondaryLinkTitle,credits=None,sortfield="weight",coords=None,RESPONSE=None,imageTag="",bgcolour="",location=None,isAlwaysClickable=None,prefix="",suffix="",isVisible=True): |
| """Aenderung der Properties""" | |
| self.secondaryLink=secondaryLink | |
| self.secondaryLinkTitle=secondaryLinkTitle | |
| self.imageTag=imageTag | self.imageTag=imageTag |
| coordsnew=[ string.split(x,",") for x in coords] | self.bgcolour=bgcolour |
| self.location=location | |
| self.isAlwaysClickable=isAlwaysClickable | |
| self.prefix=prefix[0:] | |
| self.suffix=suffix[0:] | |
| self.setIsVisible(isVisible) | |
| setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight,coordsnew) | setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight) |
| self.coords=coordsnew[0:] | |
| self.sortfield=sortfield | self.sortfield=sortfield |
| if RESPONSE is not None: | if RESPONSE is not None: |
| RESPONSE.redirect('manage_main') | RESPONSE.redirect('manage_main') |
| security.declarePublic('index_html') | 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""" |
| if 'ECHO_overview.html' in self.__dict__.keys(): | # use ECHO_overview.html template in this instance |
| return getattr(self,'ECHO_overview.html')() | if 'ECHO_overview.html' in self: |
| pt=PageTemplateFile('Products/ECHO_content/zpt/ECHO_content_overview.zpt').__of__(self) | return self['ECHO_overview.html']() |
| # use ECHO_overview_main template in path | |
| if hasattr(self, 'ECHO_overview_main'): | |
| return getattr(self, 'ECHO_overview_main')() | |
| # use template from Product | |
| pt=zptFile(self, 'zpt/ECHO_content_overview.zpt') | |
| return pt() | return pt() |
| security.declareProtected('View','index_html') | |
| 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 | |
| # old Zope 2.9 method | |
| #if 'index.html' in self.__dict__.keys(): | |
| # ret=getattr(self,'index.html')() | |
| # use Zope 2.12 IContainer for child access | |
| if 'index.html' in self: | |
| # use index.html template if it exists | |
| ret = self['index.html']() | |
| elif 'overview' in self: | |
| # use red-rectangle template when there's an 'overview' | |
| ret=self.showOverview() | |
| # use getattr for acquisition | |
| elif hasattr(self,'collection_index_template'): | |
| # use 'collection_index_template' in acquisition path | |
| ret=self.collection_index_template() | |
| elif hasattr(self,'main_index_template'): | |
| # use 'main_index_template' in acquisition path | |
| ret=self.main_index_template.__of__(self)(self.main_template) | |
| if 'index.html' in self.__dict__.keys(): | else: |
| return getattr(self,'index.html')() | # use template from Product |
| elif 'overview' in self.__dict__.keys(): | pt=zptFile(self, 'zpt/ECHO_main_index_template_standard.zpt') |
| return self.showOverview() | pt.content_type="text/html" |
| ret=pt.render() | |
| self.ZCacheable_set(ret) | |
| return ret | |
| security.declarePublic('content_html') | |
| def content_html(self,**argv): | |
| """template fuer content""" | |
| #print "NN",argv | |
| ret = ECHO_basis.content_html(self,'collection') | |
| if type(ret) is StringType: | |
| return ret.decode('utf-8') | |
| else: | |
| return ret | |
| pt=PageTemplateFile('Products/ECHO_content/zpt/ECHO_content_standard.zpt').__of__(self) | |
| pt.contentType="text/html" | |
| return pt() | |
| def getCredits(self): | def getCredits(self): |
| """Ausgabe der credits""" | """Ausgabe der credits""" |
| Line 649 class ECHO_collection(Folder, Persistent | Line 1523 class ECHO_collection(Folder, Persistent |
| else: | else: |
| return [] | return [] |
| def area_img(self): | |
| """area image""" | |
| bt = browserType(self) | |
| if bt['isIE'] or bt['isN4']: | |
| return sendFile(self, 'images/red.gif', 'image/gif') | |
| else: | |
| return sendFile(self, 'images/reda.png', 'image/png') | |
| def trans_img(self): | |
| """empty image""" | |
| return sendFile(self, 'images/trans.gif', 'image/gif') | |
| def hl_lib_js(self): | |
| """javascript""" | |
| return sendFile(self, 'js/hl_lib.js', 'text/plain') | |
| def js_lib_js(self): | |
| """javascript -- old name""" | |
| return sendFile(self, 'js/baselib.js', 'text/plain') | |
| def getGraphicCoords(self): | def baselib_js(self): |
| """javascript""" | |
| return sendFile(self, 'js/baselib.js', 'text/plain') | |
| def hl_add_js(self): | |
| """javascript""" | |
| return sendFile(self, 'js/hl_add.js', 'text/plain') | |
| def getAllMapAreas(self,mapColTypes=None): | |
| """Give list of coordinates""" | """Give list of coordinates""" |
| subColTypes=['ECHO_collection','ECHO_externalLink','ECHO_resource'] | if mapColTypes is None: |
| ids=[] | mapColTypes=['ECHO_collection','ECHO_resource','ECHO_link','ECHO_externalLink'] |
| for entry in self.__dict__.keys(): | |
| object=getattr(self,entry) | areas=[] |
| try: | for entry in self.getSubCols(subColTypes=mapColTypes): |
| if object.meta_type in subColTypes: | object=entry |
| for coordtemp in object.coords: | areas.extend(object.getMapAreas()) |
| if len(coordtemp)>3: | return areas |
| coord=coordtemp[0:4] | |
| if hasattr(object,'label') and not object.label=="": | |
| ids.append([string.join(coord,", "),object.getId(),object.label,object]) | def deleteMapAreas(self): |
| elif hasattr(object,'title'): | """deletes all map areas from this object""" |
| if not object.title=="": | for obs in self.ZopeFind(self, obj_metatypes=['MapArea'], search_sub=1): |
| ids.append([string.join(coord,", "),object.getId(),object.title,object]) | ob = obs[1] |
| id = ob.id | |
| parent = ob.aq_parent | |
| print "deleting: ", ob.id | |
| parent._delObject(id) | |
| return "Done" | |
| getSubCols = ECHO_helpers.getSubCols | |
| def getSubcolsXMLRpc(self,searchSimple): | |
| """simplesearch results suitable for xml rpc, gives back array objid,url""" | |
| return [x.absolute_url() for x in self.getSubCols(searchSimple=searchSimple)] | |
| Globals.InitializeClass(ECHO_collection) | |
| def manage_addECHO_collectionForm(self): | |
| """Add collection form""" | |
| pt=zptFile(self, 'zpt/AddECHO_collectionForm.zpt') | |
| return pt() | |
| def manage_addECHO_collection(self,id,title,label,description="",contentType="",responsible="",weight=0,sortfield="weight",coords="",secondaryLinkTitle="",secondaryLink="",credits=None,RESPONSE=None,imageTag="",bgcolour="",isVisible=True): | |
| """add a echo collection""" | |
| newObj=ECHO_collection(id,title,label,description,contentType,responsible,credits,weight,sortfield,coords,secondaryLinkTitle=secondaryLinkTitle,secondaryLink=secondaryLink,imageTag=imageTag,bgcolour="",isVisible=isVisible) | |
| self._setObject(id,newObj) | |
| if RESPONSE is not None: | |
| RESPONSE.redirect('manage_main') | |
| class ECHO_group(ECHO_collection): | |
| """ECHO Gruppe""" | |
| security=ClassSecurityInfo() | |
| meta_type="ECHO_group" | |
| manage_options = Folder.manage_options+( | |
| {'label':'Main Config','action':'ECHO_group_config'}, | |
| {'label':'Rerender Links','action':'ECHO_rerenderLinksMDWarning'}, | |
| {'label':'Graphic Coords','action':'ECHO_graphicEntry'}, | |
| ) | |
| 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+=self.unicodify(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): | |
| """standard page""" | |
| displayedObjects=self.ZopeFind(self,obj_metatypes=displayTypes) | |
| #if (len(displayedObjects)==1) and (displayedObjects[0][1].meta_type=="ECHO_collection"): # nur ein Object dann redirect auf dieses Object | |
| # return self.REQUEST.RESPONSE.redirect(displayedObjects[0][1].absolute_url()) | |
| if 'index.html' in self.__dict__.keys(): | |
| return getattr(self,'index.html')() | |
| elif 'overview' in self.__dict__.keys(): | |
| return self.showOverview() | |
| elif hasattr(self,'group_index_template'): | |
| return self.group_index_template() | |
| elif hasattr(self,'collection_index_template'): | |
| return self.collection_index_template() | |
| elif hasattr(self,'main_index_template'): | |
| return self.main_index_template() | |
| pt=zptFile(self, 'zpt/ECHO_main_index_template_standard.zpt') | |
| pt.content_type="text/html" | |
| return pt() | |
| def ECHO_group_config(self): | |
| """Main configuration""" | |
| if not hasattr(self,'weight'): | |
| self.weight="" | |
| if not hasattr(self,'sortfield'): | |
| self.sortfield="weight" | |
| if not hasattr(self,'coords'): | |
| self.coords=[] | |
| pt=zptFile(self, 'zpt/ChangeECHO_group.zpt') | |
| 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=""): | |
| """Aenderung der Properties""" | |
| self.secondaryLink=secondaryLink | |
| self.secondaryLinkTitle=secondaryLinkTitle | |
| self.imageTag=imageTag | |
| self.bgcolour=bgcolour | |
| self.logo=logo | |
| setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight) | |
| self.sortfield=sortfield | |
| if RESPONSE is not None: | |
| RESPONSE.redirect('manage_main') | |
| def getLogo(self): | |
| """logo ausgeben""" | |
| try: | |
| return self.logo | |
| except: | |
| return "ECHO_groups" | |
| security.declarePublic('content_html') | |
| def content_html(self): | |
| """template fuer content""" | |
| return ECHO_basis.content_html(self,'group') | |
| def manage_addECHO_groupForm(self): | |
| """Add group form""" | |
| pt=zptFile(self, 'zpt/AddECHO_groupForm.zpt') | |
| return pt() | |
| def manage_addECHO_group(self,id,title,label,description,contentType,responsible,weight,sortfield,coords="",secondaryLinkTitle="",secondaryLink="",credits=None,RESPONSE=None,imageTag="",bgcolour="",logo=""): | |
| """add a echo group""" | |
| newObj=ECHO_group(id,title,label,description,contentType,responsible,credits,weight,sortfield,coords,secondaryLinkTitle=secondaryLinkTitle,secondaryLink=secondaryLink,imageTag=imageTag,bgcolour="") | |
| setattr(newObj,'logo',logo) | |
| self._setObject(id,newObj) | |
| if RESPONSE is not None: | |
| RESPONSE.redirect('manage_main') | |
| Globals.InitializeClass(ECHO_group) | |
| class ECHO_userFolder(UserFolder): | |
| """User folder for Intranet""" | |
| _domain_auth_mode=1 # Identification via domain | |
| meta_type="ECHO_userFolder" | |
| def authenticate(self, name, password, request): | |
| emergency = self._emergency_user | |
| if name is None: | |
| return None | |
| if emergency and name==emergency.getUserName(): | |
| user = emergency | |
| else: | else: |
| ids.append([string.join(coord,", "),object.getId(),object.getId(),object]) | user = self.getUser(name) |
| if user is not None and user.authenticate(password, request): | |
| return user | |
| else: | else: |
| ids.append([string.join(coord,", "),object.getId(),object.getId(),object]) | return None |
| except: | def domainSpecMatch(self,spec, request): |
| """nothing""" | host='' |
| addr='' | |
| # Fast exit for the match-all case | |
| if len(spec) == 1 and spec[0] == '*': | |
| return 1 | |
| if request.has_key('REMOTE_HOST'): | |
| host=request['REMOTE_HOST'] | |
| if request.has_key('REMOTE_ADDR'): | |
| addr=request['REMOTE_ADDR'] | |
| if request.has_key('HTTP_X_FORWARDED_FOR'): | |
| addr=request['HTTP_X_FORWARDED_FOR'] | |
| if not host and not addr: | |
| return 0 | |
| if not host: | |
| try: host=socket.gethostbyaddr(addr)[0] | |
| except: pass | |
| if not addr: | |
| try: addr=socket.gethostbyname(host) | |
| except: pass | |
| _host=host.split('.') | |
| _addr=addr.split('.') | |
| _hlen=len(_host) | |
| _alen=len(_addr) | |
| for ob in spec: | |
| sz=len(ob) | |
| _ob=ob.split('.') | |
| _sz=len(_ob) | |
| mo = addr_match(ob) | |
| if mo is not None: | |
| if mo.end(0)==sz: | |
| fail=0 | |
| for i in range(_sz): | |
| a=_addr[i] | |
| o=_ob[i] | |
| if (o != a) and (o != '*'): | |
| fail=1 | |
| break | |
| if fail: | |
| continue | |
| return 1 | |
| mo = host_match(ob) | |
| if mo is not None: | |
| if mo.end(0)==sz: | |
| if _hlen < _sz: | |
| continue | |
| elif _hlen > _sz: | |
| _item=_host[-_sz:] | |
| else: | |
| _item=_host | |
| fail=0 | |
| for i in range(_sz): | |
| h=_item[i] | |
| o=_ob[i] | |
| if (o != h) and (o != '*'): | |
| fail=1 | |
| break | |
| if fail: | |
| continue | |
| return 1 | |
| return 0 | |
| # ROC: problem with 2.12 | |
| #Globals.default__class_init__(ECHO_userFolder) | |
| return ids | |
| def getSubCols(self,sortfield="weight"): | |
| subColTypes=['ECHO_collection','ECHO_externalLink','ECHO_resource'] | def manage_addECHO_userFolder(self,dtself=None,REQUEST=None,**ignored): |
| ids=[] | """add a user folder """ |
| for entry in self.__dict__.keys(): | f=ECHO_userFolder() |
| object=getattr(self,entry) | self=self.this() |
| try: | try: self._setObject('acl_users', f) |
| if object.meta_type in subColTypes: | except: return MessageDialog( |
| ids.append(object) | title ='Item Exists', |
| message='This object already contains a User Folder', | |
| action ='%s/manage_main' % REQUEST['URL1']) | |
| self.__allow_groups__=f | |
| if REQUEST is not None: | |
| REQUEST['RESPONSE'].redirect(self.absolute_url()+'/manage_main') | |
| def manage_addECHO_userFolderForm(self): | |
| """add a user folder form""" | |
| 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": | |
| except: | |
| """nothing""" | |
| try: | try: |
| sortfield=self.sortfield | manage_addECHO_collection(self,id,name,name,"","","","","") |
| except: | except: |
| """nothing""" | self.REQUEST.RESPONSE.write("<p>Error%s</p>\n"%id) |
| self.REQUEST.RESPONSE.write("<p>Creates:%s</p>\n"%getattr(self,id).absolute_url()) | |
| tmplist=[] | return type,getattr(self,id),urn |
| for x in ids: | |
| if hasattr(x,sortfield): | if type=="CDLI_item": |
| try: | try: |
| x=int(x) | manage_addECHO_resource(self,id,name,name,"","",urn,"","") |
| except: | except: |
| """nothing""" | self.REQUEST.RESPONSE.write("<p>Error%s</p>\n"%id) |
| tmp=getattr(x,sortfield) | self.REQUEST.RESPONSE.write("<p>Creates:%s</p>\n"%getattr(self,id).absolute_url()) |
| else: | |
| tmp=10000000 | |
| tmplist.append((tmp,x)) | |
| tmplist.sort() | |
| return [x for (key,x) in tmplist] | |
| return "XX" | |
| class ECHO_copyrightType(Folder,ECHO_basis): | |
| """copyright typ""" | |
| def manage_addECHO_collectionForm(self): | meta_type="ECHO_copyrightType" |
| """Add collection form""" | |
| pt=PageTemplateFile('Products/ECHO_content/zpt/AddECHO_collectionForm.zpt').__of__(self) | def __init__(self,id,title,label,url): |
| """init""" | |
| self.id=id | |
| self.title=title | |
| self.label=label | |
| self.url=url | |
| manage_options = Folder.manage_options+( | |
| {'label':'Main Config','action':'ECHO_copyrightType_config_mainForm'}, | |
| ) | |
| def ECHO_copyrightType_config_mainForm(self): | |
| """change form""" | |
| pt=zptFile(self, 'zpt/ChangeECHO_copyrightType') | |
| pt.content_type="text/html" | |
| return pt() | return pt() |
| def ECHO_copyrightType_config_main(self,title,label,url,RESPONSE=None): | |
| """change""" | |
| self.title=title | |
| self.label=label | |
| self.url=url | |
| if RESPONSE is not None: | |
| RESPONSE.redirect('manage_main') | |
| def manage_addECHO_copyrightTypeForm(self): | |
| """Form for adding a ressource""" | |
| pt=zptFile(self, 'zpt/AddECHO_copyrightTypeForm.zpt') | |
| return pt() | |
| def manage_addECHO_collection(self,id,title,label,description,contentType,responsible,weight,sortfield,coords="",credits=None,RESPONSE=None,imageTag=""): | |
| """add a echo collection""" | |
| def manage_addECHO_copyrightType(self,id,title,label,url,RESPONSE=None): | |
| """addaresource""" | |
| newObj=ECHO_collection(id,title,label,description,contentType,responsible,credits,weight,sortfield,coords,imageTag) | newObj=ECHO_copyrightType(id,title,label,url) |
| self._setObject(id,newObj) | self._setObject(id,newObj) |
| if RESPONSE is not None: | if RESPONSE is not None: |
| RESPONSE.redirect('manage_main') | RESPONSE.redirect('manage_main') |
| class ECHO_root(Folder,Persistent,Implicit): | |
| """ECHO Root Folder""" | |
| meta_type="ECHO_root" | |
| def patchContentType(self,obj=None): | |
| """austauschen content_type with contentType (patch bei umstieg von alter Version)""" | |
| class ECHO_linkList(ZopePageTemplate,ECHO_basis): | |
| """LinkList Objekt""" | |
| meta_type="ECHO_linkList" | |
| if not obj: | _default_content_fn = os.path.join(package_home(globals()), 'html/ECHO_pageTemplateDefault.html') |
| obj = self | |
| entries=obj.ZopeFind(obj,obj_metatypes=['ECHO_resource','ECHO_collection,ECHO_externalLink']) | manage_options = ZopePageTemplate.manage_options+( |
| {'label':'Main Config','action':'changeECHO_linkListWeightForm'}, | |
| ) | |
| for entry in entries: | def content_html(self): |
| """content_html""" | |
| return ECHO_basis.content_html(self,'pageTemplate') | |
| def changeECHO_linkListWeightForm(self): | |
| """change""" | |
| pt=zptFile(self, 'zpt/ChangeECHO_linkListTemplate.zpt') | |
| return pt() | |
| entry[1].contentType == entry[1].content_type | def changeECHO_linkListWeight(self,contentType,label,RESPONSE=None): |
| """change""" | |
| self.contentType=contentType | |
| self.label=label | |
| if entry[1].meta_type == 'ECHO_collection': | if RESPONSE is not None: |
| entry[1].patchContentType(entry[1]) | RESPONSE.redirect('manage_main') |
| def getLabel(self): | |
| if hasattr(self,'label'): | |
| return self.label.encode('utf-8') | |
| else: | |
| return 0 | |
| return "Rerenderd all links to resources in: "+self.title | def getcontentType(self): |
| """get contentType""" | |
| if hasattr(self,'contentType'): | |
| return normalizeCt(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 = '' | |
| if content_type is None: | |
| content_type = self.content_type | |
| self.pt_edit(text, contentType) | |
| def ECHO_newViewerLink(self,obj=None): | |
| """change links (:86 faellt weg)""" | |
| if not obj: | |
| obj = self | |
| entries=obj.ZopeFind(obj,obj_metatypes=['ECHO_resource','ECHO_collection']) | |
| for entry in entries: | def manage_addECHO_linkListForm(self): |
| """Form for adding""" | |
| pt=zptFile(self, 'zpt/AddECHO_linkListTemplate.zpt') | |
| return pt() | |
| if entry[1].meta_type == 'ECHO_resource': | |
| entry[1].link=re.sub('\:86','',entry[1].link) | 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: | 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, urllib.quote(id)) | |
| REQUEST.RESPONSE.redirect(u+'/manage_main') | |
| return '' | |
| class ECHO_support(Folder,ECHO_basis): | |
| """gefoerdert durch""" | |
| meta_type="ECHO_support" | |
| entry[1].ECHO_newViewerLink(entry[1]) | |
| return "Rerenderd all links to resources in: "+self.title | |
| def __init__(self,id,title): | def __init__(self,id,institutions=None): |
| """init""" | """init""" |
| self.id = id | self.id = id |
| self.title=title | self.title='' |
| self.institutions=toList(institutions) | |
| def deleteSpace(self,str): | def getSupporter(self): |
| """delete space at the end of a line""" | """return institutions""" |
| if str[len(str)-1]==" ": | if self.institutions: |
| return str[0:len(str)-1] | return self.institutions |
| else: | else: |
| return str | return [] |
| manage_options = Folder.manage_options+( | |
| {'label':'Main Config','action':'ECHO_support_configForm'}, | |
| ) | |
| def ECHO_support_configForm(self): | |
| """change form""" | |
| pt=zptFile(self, 'zpt/ChangeECHO_support') | |
| pt.content_type="text/html" | |
| return pt() | |
| def ECHO_support_config(self,institutions=None,RESPONSE=None): | |
| """change""" | |
| self.institutions=toList(institutions) | |
| # zusaetliche methoden fuer das vlp muessen in ein eigenes produkt | if RESPONSE is not None: |
| RESPONSE.redirect('manage_main') | |
| def formatAscii(self,str,url=None): | |
| """ersetze ascii umbrueche durch <br>""" | |
| #url=None | |
| if url: | |
| retStr="" | def manage_addECHO_supportForm(self): |
| words=str.split("\n") | """Form for adding""" |
| pt=zptFile(self, 'zpt/AddECHO_support.zpt') | |
| return pt() | |
| for word in words: | def manage_addECHO_support(self, id,institutions=None,RESPONSE=None): |
| strUrl=url%word | """add the copyright""" |
| print "str",strUrl | |
| retStr+="""<a href="%s">%s</a><br/>"""%(strUrl,word) | |
| str=retStr | |
| if str: | |
| return re.sub(r"[\n]","<br/>",str) | |
| else: | |
| return "" | |
| def link2html(self,str): | meta_type="ECHO_support" |
| """link2html fuer VLP muss hier noch raus""" | |
| if str: | |
| print str | |
| str=re.sub("\&","&",str) | |
| dom=xml.dom.minidom.parseString("<?xml version='1.0' ?><txt>"+str+"</txt>") | |
| links=dom.getElementsByTagName("link") | |
| print "link",links | |
| for link in links: | |
| link.tagName="a" | |
| ref=link.getAttribute("ref") | |
| if self.checkRef(ref): | |
| link.setAttribute("href",self.aq_parent.absolute_url()+"/vlp_coll?id="+ref) | |
| return dom.toxml('utf-8') | |
| return "" | |
| self._setObject(id, ECHO_support(id,institutions)) | |
| def checkRef(self,ref): | if RESPONSE is not None: |
| dbs={'vl_literature':'AND CD LIKE \'%lise%\'','vl_technology':'','vl_people':''} | RESPONSE.redirect('manage_main') |
| res=None | |
| for db in dbs.keys(): | # ECHO - owner of original |
| #print ref,"select reference from %s where reference =\'%s\' %s"%(db,ref,dbs[db]) | class ECHO_ownerOriginal(Folder,ECHO_basis): |
| """besitzer des originals""" | |
| meta_type="ECHO_ownerOriginal" | |
| security=ClassSecurityInfo() | |
| def __init__(self,id,institutions=None): | |
| """init""" | |
| self.id=id | |
| self.title='' | |
| self.institutions=toList(institutions) | |
| security.declarePublic('getOwner') | |
| def getOwner(self): | |
| """return institutions""" | |
| if self.institutions: | |
| return self.institutions | |
| else: | |
| return [] | |
| res=res or self.search(var=str("select reference from %s where reference =\'%s\' %s"%(db,ref,dbs[db]))) | manage_options = Folder.manage_options+( |
| return res | {'label':'Main Config','action':'ECHO_ownerOriginal_configForm'}, |
| ) | |
| #Ende Methode fuer vlp | def ECHO_ownerOriginal_configForm(self): |
| """change form""" | |
| pt=zptFile(self, 'zpt/ChangeECHO_ownerOriginal') | |
| pt.content_type="text/html" | |
| return pt() | |
| def PgQuoteString(self,string): | def ECHO_ownerOriginal_config(self,institutions=None,RESPONSE=None): |
| """Quote string""" | """change""" |
| #print "PG",string | self.institutions=toList(institutions) |
| return libpq.PgQuoteString(string) | |
| def getPartners(self): | if RESPONSE is not None: |
| """Get list of Partners. Presently only from a subfolder partners""" | RESPONSE.redirect('manage_main') |
| return [ item[1] for item in self.partners.ZopeFind(self.partners,obj_metatypes=['ECHO_partner'])] | |
| def manage_addECHO_ownerOriginalForm(self): | |
| """Form for adding""" | |
| pt=zptFile(self, 'zpt/AddECHO_ownerOriginal.zpt') | |
| return pt() | |
| def manage_addECHO_ownerOriginal(self, id,institutions=None,RESPONSE=None): | |
| """add the copyright""" | |
| meta_type="ECHO_ownerOriginal" | |
| def getPartnersXML(self): | self._setObject(id, ECHO_ownerOriginal(id,institutions)) |
| """partner liste als xml""" | |
| partners=self.getPartners() | |
| ret="<partners>" | |
| for partner in partners: | |
| ret+="""<partner id="%s" title="%s"/>\n"""%(partner.getId(),partner.title) | |
| return ret+"\n</partners>" | if RESPONSE is not None: |
| RESPONSE.redirect('manage_main') | |
| def getCollectionTree(self): | # -------------------------------------------------------------------------------- |
| """get the collection tree (list of triples (parent,child, depth)""" | |
| def getCollection(object,depth=0): | # ECHO - digitized copy by |
| depth+=1 | class ECHO_digiCopyBy(Folder,ECHO_basis): |
| collections=[] | """besitzer des originals""" |
| for entry in object.__dict__.keys(): | meta_type="ECHO_digiCopyBy" |
| element=getattr(object,entry) | security=ClassSecurityInfo() |
| try: | |
| if element.meta_type=="ECHO_collection": | |
| collections.append((object,element,depth)) | |
| collections+=getCollection(element,depth) | |
| except: | |
| """nothing""" | |
| return collections | |
| return getCollection(self) | def __init__(self,id,institutions=None): |
| """init""" | |
| self.id=id | |
| self.title='' | |
| self.institutions=toList(institutions) | |
| def getCollectionTreeIds(self): | security.declarePublic('getDigiCopyBy') |
| """Show the IDs of the Tree""" | def getDigiCopyBy(self): |
| ret=[] | """return institutions""" |
| for collection in self.getCollectionTree(): | if self.institutions: |
| ret.append((collection[0].getId(),collection[1].getId(),collection[2])) | return self.institutions |
| return ret | else: |
| return [] | |
| manage_options = Folder.manage_options+( | |
| {'label':'Main Config','action':'ECHO_digiCopyBy_configForm'}, | |
| ) | |
| def ECHO_digiCopyBy_configForm(self): | |
| """change form""" | |
| pt=zptFile(self, 'zpt/ChangeECHO_digiCopyBy') | |
| pt.content_type="text/html" | |
| return pt() | |
| def manage_addECHO_root(self,id,title,RESPONSE=None): | def ECHO_digiCopyBy_config(self,institutions=None,RESPONSE=None): |
| """Add an ECHO_root""" | """change""" |
| self._setObject(id,ECHO_root(id,title)) | self.institutions=toList(institutions) |
| if RESPONSE is not None: | if RESPONSE is not None: |
| RESPONSE.redirect('manage_main') | RESPONSE.redirect('manage_main') |
| def manage_addECHO_rootForm(self): | |
| """Nothing yet""" | def manage_addECHO_digiCopyByForm(self): |
| pt=PageTemplateFile('Products/ECHO_content/zpt/AddECHO_root.zpt').__of__(self) | """Form for adding""" |
| pt=zptFile(self, 'zpt/AddECHO_digiCopyBy.zpt') | |
| return pt() | return pt() |
| class ECHO_partner(Image,Persistent): | def manage_addECHO_digiCopyBy(self, id,institutions=None,RESPONSE=None): |
| """ECHO Partner""" | """add the copyright""" |
| meta_type="ECHO_partner" | meta_type="ECHO_digiCopyBy" |
| self._setObject(id, ECHO_digiCopyBy(id,institutions)) | |
| if RESPONSE is not None: | |
| RESPONSE.redirect('manage_main') | |
| # -------------------------------------------------------------------------------- | |
| class ECHO_institution(Image,Persistent,ECHO_basis): | |
| """ECHO Institution""" | |
| def __init__(self, id, title,url, file, contentType='', precondition=''): | meta_type="ECHO_institution" |
| def __init__(self, id, title,url, file, person, email, country, 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.email=email | |
| self.country=country | |
| self.precondition=precondition | self.precondition=precondition |
| data, size = self._read_data(file) | data, size = self._read_data(file) |
| contentType=self._get_contentType(file, data, id, contentType) | content_type=self._get_content_type(file, data, id, content_type) |
| self.update_data(data, contentType, size) | self.update_data(data, content_type, size) |
| manage_options = Image.manage_options+( | manage_options = Image.manage_options+( |
| {'label':'Partner Information','action':'ECHO_partner_config'}, | {'label':'Institution Information','action':'ECHO_institution_config'}, |
| ) | ) |
| def changeECHO_partner(self,url,RESPONSE=None): | |
| def changeECHO_institution(self,url,person, email, country,RESPONSE=None): | |
| """Change main information""" | """Change main information""" |
| self.url=url | self.url=url |
| self.person=person | |
| self.email=email | |
| self.country=country | |
| if RESPONSE is not None: | if RESPONSE is not None: |
| RESPONSE.redirect('manage_main') | RESPONSE.redirect('manage_main') |
| def ECHO_partner_config(self): | def ECHO_institution_config(self): |
| """Main configuration""" | """Main configuration""" |
| if not hasattr(self,'url'): | if not hasattr(self,'url'): |
| self.url="" | self.url="" |
| pt=PageTemplateFile('Products/ECHO_content/zpt/ChangeECHO_partner.zpt').__of__(self) | pt=zptFile(self, 'zpt/ChangeECHO_institution.zpt') |
| return pt() | return pt() |
| manage_addECHO_partnerForm=DTMLFile('dtml/ECHO_partnerAdd',globals(), | manage_addECHO_institutionForm=DTMLFile('dtml/ECHO_institutionAdd',globals(), |
| Kind='ECHO_partner',kind='ECHO_partner') | Kind='ECHO_institution',kind='ECHO_institution') |
| def manage_addECHO_partner(self, id, file,url, title='', precondition='', contentType='', | def manage_addECHO_institution(self, id, url, person, email, country, file=None, title='', precondition='', content_type='', |
| REQUEST=None): | REQUEST=None): |
| """ | """ |
| Add a new ECHO_partner object. | Add a new ECHO_institution object. |
| Creates a new ECHO_partner object 'id' with the contents of 'file'. | Creates a new ECHO_institution object 'id' with the contents of 'file'. |
| Based on Image.manage_addImage | Based on Image.manage_addImage |
| """ | """ |
| id=str(id) | id=str(id) |
| title=str(title) | title=str(title) |
| contentType=str(contentType) | content_type=str(content_type) |
| precondition=str(precondition) | precondition=str(precondition) |
| id, title = OFS.Image.cookId(id, title, file) | id, title = OFS.Image.cookId(id, title, file) |
| Line 960 def manage_addECHO_partner(self, id, fil | Line 2253 def manage_addECHO_partner(self, id, fil |
| 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,'',contentType, precondition)) | 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 | # 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. |
| if file: | if file: |
| self._getOb(id).manage_upload(file) | self._getOb(id).manage_upload(file) |
| if contentType: | if content_type: |
| self._getOb(id).contentType=contentType | self._getOb(id).content_type=content_type |
| if REQUEST is not None: | if REQUEST is not None: |
| try: url=self.DestinationURL() | try: url=self.DestinationURL() |
| Line 975 def manage_addECHO_partner(self, id, fil | Line 2268 def manage_addECHO_partner(self, id, fil |
| REQUEST.RESPONSE.redirect('%s/manage_main' % url) | REQUEST.RESPONSE.redirect('%s/manage_main' % url) |
| return id | return id |
| def repairCoords(self): | |
| """updates map coordinates to new MapArea objects""" | |
| msg = "" | |
| for cols in self.ZopeFind(self, obj_metatypes=['ECHO_collection','ECHO_resource'], search_sub=1): | |
| col = cols[1] | |
| if not hasattr(col, 'coords'): | |
| continue | |
| print "fixing: ", col.id | |
| msg += "fixing: "+col.id+"\n" | |
| coords = col.coords | |
| if len(coords) > 0: | |
| # delete old MapAreas | |
| for areas in self.ZopeFind(col, obj_metatypes=['MapArea']): | |
| #area = areas[1] | |
| id = areas[0] | |
| print " deleting: ", id | |
| msg += " deleting: "+id+"\n" | |
| col._delObject(id) | |
| # add new MapAreas | |
| areacnt = 0 | |
| for coord in coords: | |
| if len(coord) < 4: | |
| continue | |
| type = col.viewClassification | |
| if type == 'view point': | |
| type = 'arrow' | |
| if type is None: | |
| if len(coord) > 4: | |
| type = 'arrow' | |
| else: | |
| type = 'area' | |
| newid = "a%02d"%areacnt | |
| areacnt += 1 | |
| area = MapArea(newid, coord, type=type) | |
| print " adding: ", newid | |
| msg += " adding: "+newid+"\n" | |
| col.addMapArea(area) | |
| msg += "\nDone!" | |
| return msg | |
| from ECHO_root import ECHO_main | |
| #class ECHO_main(ECHO_root,ECHO_navigation): | |
| # """echo main object combines ECHO_root and ECHO_navigation""" | |
| # | |
| # meta_type="ECHO_main" | |
| # | |
| # def __init__(self,id,title): | |
| # """init""" | |
| # self.id=id | |
| # self.title=title | |
| # self.pathToHierarchy="/"+self.id # hierarchie always starts with the object. | |
| # self.displayedMetaTypes=displayTypes | |
| # | |
| # | |
| # manage_options = Folder.manage_options+( | |
| # {'label':'Main Config','action':'ECHO_navigationConfigForm'}, | |
| # {'label':'Cache','action':'ECHO_cacheManageForm'}, | |
| # {'label':'Main Config','action':'ECHO_copyright_configForm'}, | |
| # {'label':'Change Weights','action':'changeWeights'}, | |
| # {'label':'Generate from RDF','action':'generateFromRDFForm'}, | |
| # {'label':'update Resource Catalog','action':'updateResourceCatalog'}, | |
| # {'label':'Copy MD for indexing and search','action':'copySearchFields'}, | |
| # ) | |
| # | |
| # | |
| #def manage_addECHO_mainForm(self): | |
| # """Form for adding""" | |
| # pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','AddECHO_main.zpt')).__of__(self) | |
| # return pt() | |
| # | |
| #def manage_addECHO_main(self,id,title,RESPONSE=None): | |
| # """Add an ECHO_main""" | |
| # self._setObject(id,ECHO_main(id,title)) | |
| # | |
| # obj=self._getOb(id) | |
| # text=file(os.path.join(package_home(globals()),'zpt','main_template')).read() | |
| # | |
| # manage_addPageTemplate(obj,'main_template',text=text) | |
| # | |
| # | |
| # if RESPONSE is not None: | |
| # RESPONSE.redirect('manage_main') |