version 1.1.1.1, 2003/11/25 11:19:47
|
version 1.310.2.9, 2012/09/03 13:11:09
|
Line 1
|
Line 1
|
|
"""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 8 class ECHO_resource contains information
|
Line 8 class ECHO_resource contains information
|
class ECHO_externalLink contains information on externalLinks |
class ECHO_externalLink contains information on externalLinks |
|
|
|
|
|
|
""" |
""" |
|
|
|
|
|
import urlparse |
import string |
import string |
|
import tempfile |
|
import zipfile |
|
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 Products.ZCatalog.CatalogPathAwareness import CatalogAware |
|
from Products.ZCTextIndex.ZCTextIndex import manage_addLexicon |
|
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 |
|
import cgi |
|
import smtplib |
def toList(field): |
import time |
"""Einzelfeld in Liste umwandeln""" |
#from Ft.Xml.Domlette import NonvalidatingReader |
if type(field)==StringType: |
#from Ft.Xml.Domlette import PrettyPrint, Print |
return [field] |
#from Ft.Xml import EMPTY_NAMESPACE |
else: |
# |
return field |
#import Ft.Xml.XPath |
|
import cStringIO |
|
|
def getText(nodelist): |
import sys |
|
import logging |
|
|
rc = "" |
|
for node in nodelist: |
|
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""" |
import logging |
|
|
|
from ECHO_root import ECHO_root |
|
|
#print metadict |
#ersetzt logging.info |
return metadict,"" |
def logger(txt,method,txt2): |
|
"""logging""" |
|
logging.info(txt+ txt2) |
|
|
|
|
def setECHO_CollectionInformation(self,context,science,practice,source_type,period,id,title,label,description,content_type,responsible,credits,weight,coords): |
def setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight,coordstrs=""): |
|
|
"""Allegemeine Informationen zu einer ECHO Collection""" |
"""Allegemeine Informationen zu einer ECHO Collection""" |
|
|
self.label = label |
self.label = label |
self.title=title |
self.title=title |
self.description=description |
self.description=description |
self.content_type=content_type |
self.contentType=contentType |
self.responsible=responsible |
self.responsible=responsible |
self.credits=toList(credits) |
self.credits=toList(credits) |
self.weight=weight |
self.weight=weight |
|
|
self.scientific_Information.source_type=source_type |
import ECHO_resource |
self.scientific_Information.period=period |
from ECHO_resource import manage_addECHO_resource |
self.scientific_Information.scientific_Classification.context=context |
|
self.scientific_Information.scientific_Classification.science=science |
|
self.scientific_Information.scientific_Classification.practice=practice |
|
|
|
|
class ECHO_resource(ECHO_resource.ECHO_resource): |
|
"""depricated use class in ECHO_resource.py""" |
|
|
#coordinates of for rectangles |
|
self.coords=coords |
|
|
|
|
class ECHO_partner(Image,Persistent,ECHO_basis): |
|
"""ECHO Partner""" |
|
|
class scientificClassification(SimpleItem,Persistent,Implicit): |
meta_type="ECHO_partner" |
"""subclass""" |
|
security=ClassSecurityInfo() |
def __init__(self, id, title,url, file, copyrightType, person, email, country, color, content_type='', precondition=''): |
|
self.__name__=id |
|
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" |
|
|
def changeECHO_partner(self,url,copyrightType,person, email, country, color, RESPONSE=None): |
security.declarePublic('get_context') |
"""Change main information""" |
def get_context(self): |
self.url=url |
return self.context |
self.person=person |
|
self.email=email |
security.declarePublic('get_science') |
self.country=country |
def get_science(self): |
self.color=color |
return self.science |
self.copyrightType=copyrightType |
|
if RESPONSE is not None: |
security.declarePublic('get_practice') |
RESPONSE.redirect('manage_main') |
def get_practice(self): |
|
return self.practice |
|
|
|
|
|
class scientificInformation(Folder,Persistent,Implicit): |
|
"""subclass scientificInformation""" |
def ECHO_partner_config(self): |
security=ClassSecurityInfo() |
"""Main configuration""" |
|
if not hasattr(self,'url'): |
|
self.url="" |
|
pt=zptFile(self, 'zpt/ChangeECHO_partner.zpt') |
|
return pt() |
|
|
|
|
|
manage_addECHO_partnerForm=DTMLFile('dtml/ECHO_partnerAdd',globals(), |
|
Kind='ECHO_partner',kind='ECHO_partner') |
|
|
|
|
def __init__(self,source_type,period): |
|
|
|
self.id="scientific_Information" |
def manage_addECHO_partner(self, id, url, person, email, country, color, file=None, copyrightType='', title='', precondition='', content_type='', |
self.source_type=source_type |
REQUEST=None): |
self.period=period |
""" |
|
Add a new ECHO_partner object. |
|
|
|
Creates a new ECHO_partner 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) |
|
|
security.declarePublic('get_source_type') |
id, title = OFS.Image.cookId(id, title, file) |
def get_source_type(self): |
|
return self.source_type |
|
|
|
security.declarePublic('get_period') |
self=self.this() |
def get_period(self): |
|
return self.period |
|
|
|
|
# First, we create the image without data: |
|
self._setObject(id, ECHO_partner(id,title,url,'',copyrightType, person, email, country, color, content_type, precondition)) |
|
|
class ECHO_resource(Folder): |
# Now we "upload" the data. By doing this in two steps, we |
"""ECHO Ressource""" |
# can use a database trick to make the upload more efficient. |
meta_type='ECHO_resource' |
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 |
|
|
def __init__(self,id,link,metalink,title,label,description,content_type,responsible,credits,weight,coords): |
class ECHO_locale(ZopePageTemplate): |
|
"""localisierung""" |
|
|
self.id = id |
meta_type="ECHO_locale" |
"""Festlegen der ID""" |
|
|
|
self.label = label |
def __init__(self,id,lang,title,label,text=None,content_type=None): |
self.link= link |
self.lang=lang |
self.metalink=metalink |
|
self.title=title |
self.title=title |
self.weight=weight |
self.label=label |
self.credits=toList(credits) |
# default content |
self.description=description |
if not text: |
self.content_type=content_type |
text = open(self._default_content_fn).read() |
self.responsible=responsible |
content_type = 'text/html' |
coordsnew=[ string.split(x,",") for x in coords] |
self.pt_edit(text, content_type) |
self.coords=coordsnew |
self.id=id |
|
|
|
manage_options = ZopePageTemplate.manage_options+( |
|
{'label':'Main Config','action':'change_ECHO_localeForm'}, |
|
) |
|
|
|
def change_ECHO_localeForm(self): |
|
"""change form""" |
|
pt=zptFile(self, 'zpt/ChangeECHO_localeForm.zpt') |
|
return pt() |
|
|
def ECHO_resource_config(self): |
def change_ECHO_locale(self,lang,title,label,text=None,content_type=None,RESPONSE=None): |
"""Main configuration""" |
"""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) |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
if not hasattr(self,'weight'): |
|
self.weight="" |
|
if not hasattr(self,'coords'): |
|
self.coords=[] |
|
|
|
pt=PageTemplateFile('Products/ECHO_content/ChangeECHO_resource.zpt').__of__(self) |
def manage_addECHO_localeForm(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""" |
|
|
|
id="locale_"+lang |
|
|
def changeECHO_resource(self,metalink,link,context,science,practice,source_type,period,title,label,description,content_type,responsible,credits,weight,coords,RESPONSE=None): |
self._setObject(id, ECHO_locale(id,lang,title,label,text,content_type)) |
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
"""Änderung der Properties""" |
|
|
|
|
class ECHO_copyright(Folder,ECHO_basis): |
|
"""Copyright informationen""" |
|
meta_type="ECHO_copyright" |
|
|
setECHO_CollectionInformation(self,context,science,practice,source_type,period,id,title,label,description,content_type,responsible,credits,weight,coords) |
|
|
|
|
|
self.link=link |
def __init__(self,id,title,copyrights): |
self.metalink=metalink |
"""init""" |
|
self.title=title |
|
self.id=id |
|
self.copyrights=copyrights[0:] |
|
|
|
def getCopyrights(self): |
|
"""return coyprights""" |
|
return self.copyrights |
|
|
|
manage_options = Folder.manage_options+( |
|
{'label':'Main Config','action':'ECHO_copyright_configForm'}, |
|
) |
|
|
|
|
|
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: |
if RESPONSE is not None: |
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
|
|
manage_options = Folder.manage_options+( |
def manage_addECHO_copyrightForm(self): |
{'label':'Main Config','action':'ECHO_resource_config'}, |
"""Form for adding""" |
{'label':'Metadata','action':'ECHO_getResourceMD'}, |
pt=zptFile(self, 'zpt/AddECHO_copyright.zpt') |
|
return pt() |
|
|
) |
def manage_addECHO_copyright(self, id,title,RESPONSE=None): |
|
"""add the copyright""" |
|
|
|
meta_type="ECHO_copyright" |
|
|
|
#first generate copyrights as list of tripels (mediaType,partner,copyrightType) |
|
|
|
|
def ECHO_getResourceMD(self,template="yes"): |
|
"""Einlesen der Metadaten und Anlegen dieser Metadaten als Informationen zur Resource""" |
|
(metadict, error)=readMetadata(self.metalink) |
|
|
|
#print "BLA" |
self._setObject(id, ECHO_copyright(id, title,getCopyrightsFromForm(self,self.REQUEST.form))) |
|
|
if not error=="": #Fehler beim Auslesen des Metafiles |
if RESPONSE is not None: |
return "ERROR:",error |
RESPONSE.redirect('manage_main') |
for key in metadict.keys():#Hinzufügen der Felder |
|
|
|
setattr(self,key,metadict[key].encode('ascii','replace')) |
class ECHO_layoutTemplate(ZopePageTemplate,ECHO_basis): |
|
"""Create a layout Template for different purposes""" |
|
|
|
meta_type="ECHO_layoutTemplate" |
|
|
self.metadata=metadict.keys() |
def __init__(self, id, text=None, content_type=None,EchoType=None): |
#return "BLUccssB" |
self.id = str(id) |
self.label=self.generate_label() |
|
|
|
if template=="yes": |
self.ZBindings_edit(self._default_bindings) |
pt=PageTemplateFile('Products/ECHO_content/ECHO_resourceMD.zpt').__of__(self) |
if text is None: |
|
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() |
return pt() |
|
|
def ECHO_getMD(self,item): |
|
"""Ausgabe der MD""" |
|
return getattr(self,item) |
|
|
|
def index_html(self): |
def manage_addECHO_layoutTemplate(self, EchoType,title=None,REQUEST=None): |
"""standard page""" |
"Add a Page Template with optional file content." |
|
if type(EchoType)==StringType: |
|
EchoTypes=[EchoType] |
|
else: |
|
EchoTypes=EchoType |
|
|
return self.REQUEST.RESPONSE.redirect(self.link) |
for singleType in EchoTypes: |
|
|
def generate_label(self): |
id = str(singleType)+"_template" |
"""Erzeugt_standard_Label aus Template""" |
if REQUEST is None: |
pt=getattr(self,"label_template_"+self.bib_type) |
self._setObject(id, ECHO_layoutTemplate(id, text,EchoType=singleType)) |
#return pt |
ob = getattr(self, id) |
#pt.content_type="text/html; charset=utf-8" |
|
return pt() |
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')) |
|
|
def manage_AddECHO_resourceForm(self): |
self._setObject(id, zpt) |
"""Nothing yet""" |
ob = getattr(self, id) |
pt=PageTemplateFile('Products/ECHO_content/AddECHO_resourceForm.zpt').__of__(self) |
if title: |
return pt() |
ob.pt_setTitle(title) |
|
|
|
try: |
|
u = self.DestinationURL() |
|
except AttributeError: |
|
u = REQUEST['URL1'] |
|
|
def manage_AddECHO_resource(self,context,science,practice,source_type,period,id,title,label,description,content_type,responsible,link,metalink,credits,weight,coords,RESPONSE=None): |
|
|
|
"""nothing yet""" |
REQUEST.RESPONSE.redirect(u+'/manage_main') |
scientificClassificationObj=scientificClassification(context,science,practice) |
return '' |
|
|
scientificInformationObj=scientificInformation(source_type,period) |
class ECHO_fullText(ZopePageTemplate,ECHO_basis,ECHO_language): |
|
"""echo fulltext in xml""" |
|
|
|
meta_type="ECHO_fullText" |
|
|
newObj=ECHO_resource(id,link,metalink,title,label,description,content_type,responsible,credits,weight,coords) |
|
|
|
self._setObject(id,newObj) |
def getPage(self,nr='1'): |
getattr(self,id)._setObject('scientific_Information',scientificInformationObj) |
"""get page n""" |
getattr(self,id).scientific_Information._setObject('scientific_Classification',scientificClassificationObj) |
#return self().encode('latin-1','ignore') |
if RESPONSE is not None: |
try: |
RESPONSE.redirect('manage_main') |
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." |
|
|
class ECHO_externalLink(Folder): |
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, urllib.quote(id)) |
|
REQUEST.RESPONSE.redirect(u+'/manage_main') |
|
return '' |
|
|
|
|
|
|
|
|
|
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,content_type,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 294 class ECHO_externalLink(Folder):
|
Line 452 class ECHO_externalLink(Folder):
|
self.title=title |
self.title=title |
self.weight=weight |
self.weight=weight |
self.description=description |
self.description=description |
self.content_type=content_type |
self.contentType=contentType |
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 305 class ECHO_externalLink(Folder):
|
Line 465 class ECHO_externalLink(Folder):
|
if not hasattr(self,'weight'): |
if not hasattr(self,'weight'): |
self.weight="" |
self.weight="" |
if not hasattr(self,'coords'): |
if not hasattr(self,'coords'): |
print "HI" |
|
self.coords=[''] |
|
print "G",self.coords |
|
|
|
pt=PageTemplateFile('Products/ECHO_content/ChangeECHO_externalLink.zpt').__of__(self) |
|
return pt() |
|
|
|
|
|
def changeECHO_externalLink(self,link,context,science,practice,source_type,period,title,label,description,content_type,responsible,credits,weight,coords,RESPONSE=None): |
self.coords=[''] |
|
|
"""Änderung der Properties""" |
|
|
|
|
pt=zptFile(self, 'zpt/ChangeECHO_externalLink.zpt') |
|
return pt() |
|
|
setECHO_CollectionInformation(self,context,science,practice,source_type,period,id,title,label,description,content_type,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.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 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): |
|
"""Nothing yet""" |
def manage_addECHO_externalLinkForm(self): |
pt=PageTemplateFile('Products/ECHO_content/AddECHO_externalLinkForm.zpt').__of__(self) |
"""Form for external Links""" |
|
pt=zptFile(self, 'zpt/AddECHO_externalLinkForm.zpt') |
|
return pt() |
|
|
|
|
|
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""" |
|
|
|
newObj=ECHO_externalLink(id,link,title,label,description,contentType,responsible,credits,weight,coords,linkType) |
|
|
|
self._setObject(id,newObj) |
|
|
|
if RESPONSE is not None: |
|
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() |
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] |
|
|
|
|
|
else: |
|
params={} |
|
|
|
if getattr(self,'addLinks','yes')=="yes": |
|
params['backLink']=self.aq_parent.absolute_url() |
|
params['startLink']=splitted[0]+"?"+urllib.urlencode(params) |
|
|
|
|
def manage_AddECHO_externalLink(self,context,science,practice,source_type,period,id,title,label,description,content_type,responsible,link,credits,weight,coords,RESPONSE=None): |
return self.REQUEST.RESPONSE.redirect(splitted[0]+"?"+urllib.urlencode(params)) |
|
else: |
|
return "" |
|
|
"""nothing yet""" |
def manage_addECHO_linkForm(self): |
scientificClassificationObj=scientificClassification(context,science,practice) |
"""Form for external Links""" |
|
pt=zptFile(self, 'zpt/AddECHO_linkForm.zpt') |
|
return pt() |
|
|
scientificInformationObj=scientificInformation(source_type,period) |
|
|
|
|
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_externalLink(id,link,title,label,description,content_type,responsible,credits,weight,coords) |
newObj=ECHO_link(id,link,title,label,description,contentType,responsible,credits,weight,coords,linkType) |
|
|
self._setObject(id,newObj) |
self._setObject(id,newObj) |
getattr(self,id)._setObject('scientific_Information',scientificInformationObj) |
|
getattr(self,id).scientific_Information._setObject('scientific_Classification',scientificClassificationObj) |
getattr(self,id).addLinks='no' |
|
|
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
|
|
class ECHO_collection(Folder, Persistent, Implicit): |
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): |
|
"""GetTag""" |
|
try: |
|
return self.imageTag |
|
except: |
|
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): |
|
"""SSS""" |
|
try: |
|
manage_addECHO_resource(self,id,title,label,description,responsible,link,metalink,weight,credits=None,coords=None,RESPONSE=None) |
|
return "done" |
|
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 "done" |
|
def getSecondaryLink(self): |
|
"""secondary link""" |
|
try: |
|
return self.secondaryLink |
|
except: |
|
return "" |
|
|
|
def getSecondaryLinkTitle(self): |
|
"""secondary link""" |
|
try: |
|
return self.secondaryLinkTitle |
|
except: |
|
return "" |
|
|
|
def getCollectionTreeXML(self,pwstr=None): |
|
"""Tree as XML""" |
|
|
|
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 |
|
collections="" |
|
for entry in object.__dict__.keys(): |
|
element=getattr(object,entry) |
|
try: |
|
if element.meta_type in ["ECHO_collection","ECHO_group"]: |
|
collections+="<element name=\""+urllib.quote(element.title)+"\" url=\""+addPassWd(element.absolute_url(),pwstr=pwstr)+"\">" |
|
collections+=getCollection(element,depth)+"</element>\n" |
|
except: |
|
"""nothing""" |
|
return collections |
|
|
|
ret="""<?xml version="1.0" encoding="utf-8" ?>""" |
|
return ret+"<collection>"+getCollection(self,pwstr=pwstr)+"</collection>" |
|
|
|
def createAllJSAreas(self,mapColTypes=None): |
|
"""create area calls for JavaScript""" |
|
areas = self.getAllMapAreas(mapColTypes=mapColTypes) |
|
return self.createJSAreas(areas) |
|
|
|
|
|
emptyPartner=ECHO_partner("", "","", "", "", "", "", "", "") |
|
|
security.declarePublic('getCreditObject') |
security.declarePublic('getCreditObject') |
def getCreditObject(self,name): |
def getCreditObject(self,name): |
"""credit id to credititem""" |
"""credit id to credititem""" |
|
try: |
return getattr(self.partners,name) |
return getattr(self.partners,name) |
|
except: |
|
|
|
return self.emptyPartner |
|
|
|
|
security.declarePublic('ECHO_generateNavBar') |
security.declarePublic('ECHO_generateNavBar') |
def ECHO_generateNavBar(self): |
def ECHO_generateNavBar(self): |
Line 389 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""" |
|
#print "HI" |
|
#return "OK" |
|
for entry in self.__dict__.keys(): |
|
object=getattr(self,entry) |
|
|
|
|
|
try: |
def ECHO_rerenderLinksMDWarning(self): |
|
"""change form""" |
if object.meta_type == 'ECHO_resource': |
pt=zptFile(self, 'zpt/rerenderLinksWarning') |
|
pt.content_type="text/html" |
object.ECHO_getResourceMD(template="no") |
return pt() |
|
|
except: |
|
"""nothing""" |
|
|
|
return "Rerenderd all links to resources in: "+self.title |
|
|
|
|
|
|
security.declarePublic('ECHO_rerenderLinksMD') |
|
def ECHO_rerenderLinksMD(self,obj=None,types=['title','label']): |
|
"""Rerender all Links""" |
|
return ECHO_rerenderLinksMD(self,obj,types) |
|
|
security.declarePublic('printall') |
|
def printall(self): |
|
return self.scientific_information.__dict__.keys() |
|
|
|
|
def __init__(self,id,title,label,description="",contentType="",responsible="",credits="",weight="",sortfield="",coords=[],secondaryLinkTitle="",secondaryLink="",imageTag="",bgcolour="",isVisible=True): |
def getCoords(self): |
|
try: |
|
return [ string.join(x,",") for x in self.coords] |
|
except: |
|
return [] |
|
def __init__(self,id,title,label,description,content_type,responsible,credits,weight,sortfield,coords): |
|
print "CO",coords |
|
|
|
self.id = id |
self.id = id |
"""Festlegen der ID""" |
"""Festlegen der ID""" |
Line 430 class ECHO_collection(Folder, Persistent
|
Line 1368 class ECHO_collection(Folder, Persistent
|
self.label = label |
self.label = label |
self.title=title |
self.title=title |
self.description=description |
self.description=description |
self.content_type=content_type |
self.contentType=contentType |
self.responsible=responsible |
self.responsible=responsible |
|
self.imageTag=imageTag |
self.weight=weight |
self.weight=weight |
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+ Cacheable.manage_options+( |
|
{'label':'Main Config','action':'ECHO_collection_config'}, |
|
{'label':'Change Labels','action':'changeLabels'}, |
|
{'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'}, |
|
) |
|
|
|
|
manage_options = Folder.manage_options+( |
security.declarePublic('ECHO_collection_config') |
{'label':'Main Config','action':'ECHO_Collection_config'}, |
def ECHO_collection_config(self): |
{'label':'Rerender Links','action':'ECHO_rerenderLinksMD'}, |
"""Main configuration""" |
{'label':'Graphics','action':'ECHO_graphicEntry'}, |
|
|
|
) |
if not hasattr(self,'weight'): |
|
self.weight="" |
|
|
|
if not hasattr(self,'sortfield'): |
|
self.sortfield="weight" |
|
|
def ECHO_graphicEntry(self): |
pt=zptFile(self, 'zpt/ChangeECHO_Collection.zpt') |
"""DO nothing""" |
|
if 'overview' in self.aq_parent.__dict__.keys(): |
|
pt=PageTemplateFile('Products/ECHO_content/ECHO_draw.zpt').__of__(self) |
|
return pt() |
return pt() |
|
|
|
|
|
def getBgcolour(self): |
|
"""colour""" |
|
if hasattr(self,'bgcolour') and not (self.bgcolour==""): |
|
return self.bgcolour |
|
else: |
|
return "#dddddd" |
|
|
|
|
|
security.declarePublic('changeECHO_collection') |
|
def changeECHO_collection(self,title,label,description,contentType,responsible,weight,secondaryLink,secondaryLinkTitle,credits=None,sortfield="weight",coords=None,RESPONSE=None,imageTag="",bgcolour="",location=None,isAlwaysClickable=None,prefix="",suffix="",isVisible=True): |
|
"""Aenderung der Properties""" |
|
|
|
self.secondaryLink=secondaryLink |
|
self.secondaryLinkTitle=secondaryLinkTitle |
|
self.imageTag=imageTag |
|
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) |
|
|
|
self.sortfield=sortfield |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
def setAlwaysClickable(self,flag="yes"): |
|
"""set clickable""" |
|
if flag=="yes": |
|
self.isAlwaysClickable="yes" |
else: |
else: |
return "NO OVERVIEW GRAPHICS" |
self.isAlwaysClickable=None |
|
|
def ECHO_enterCoords(self,coordstr): |
return flag |
"""Enter coords""" |
|
self.coords.append(coordstr.split(",")) |
def showOverview(self): |
pt=PageTemplateFile('Products/ECHO_content/ECHO_draw.zpt').__of__(self) |
"""overview""" |
|
# use ECHO_overview.html template in this instance |
|
if 'ECHO_overview.html' in 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.declarePublic('ECHO_Collection_config') |
security.declareProtected('View','index_html') |
def ECHO_Collection_config(self): |
def index_html(self): |
|
"""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) |
|
|
|
else: |
|
# use template from Product |
|
pt=zptFile(self, 'zpt/ECHO_main_index_template_standard.zpt') |
|
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 |
|
|
|
|
|
def getCredits(self): |
|
"""Ausgabe der credits""" |
|
if self.credits: |
|
return self.credits |
|
else: |
|
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 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""" |
|
if mapColTypes is None: |
|
mapColTypes=['ECHO_collection','ECHO_resource','ECHO_link','ECHO_externalLink'] |
|
|
|
areas=[] |
|
for entry in self.getSubCols(subColTypes=mapColTypes): |
|
object=entry |
|
areas.extend(object.getMapAreas()) |
|
return areas |
|
|
|
|
|
def deleteMapAreas(self): |
|
"""deletes all map areas from this object""" |
|
for obs in self.ZopeFind(self, obj_metatypes=['MapArea'], search_sub=1): |
|
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""" |
"""Main configuration""" |
|
|
if not hasattr(self,'weight'): |
if not hasattr(self,'weight'): |
Line 470 class ECHO_collection(Folder, Persistent
|
Line 1666 class ECHO_collection(Folder, Persistent
|
|
|
if not hasattr(self,'sortfield'): |
if not hasattr(self,'sortfield'): |
self.sortfield="weight" |
self.sortfield="weight" |
#print "HI" |
|
if not hasattr(self,'coords'): |
if not hasattr(self,'coords'): |
self.coords=[] |
self.coords=[] |
|
|
pt=PageTemplateFile('Products/ECHO_content/ChangeECHO_Collection.zpt').__of__(self) |
pt=zptFile(self, 'zpt/ChangeECHO_group.zpt') |
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=""): |
|
"""Aenderung der Properties""" |
|
|
security.declarePublic('changeECHO_Collection') |
self.secondaryLink=secondaryLink |
|
self.secondaryLinkTitle=secondaryLinkTitle |
|
self.imageTag=imageTag |
|
self.bgcolour=bgcolour |
|
self.logo=logo |
|
|
def changeECHO_Collection(self,context,science,practice,source_type,period,id,title,label,description,content_type,responsible,credits,weight,coords,sortfield="weight",RESPONSE=None): |
setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight) |
|
|
"""Änderung der Properties""" |
|
|
|
coordsnew=[ string.split(x,",") for x in coords] |
|
setECHO_CollectionInformation(self,context,science,practice,source_type,period,id,title,label,description,content_type,responsible,credits,weight,coordsnew) |
|
|
|
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 getLogo(self): |
|
"""logo ausgeben""" |
|
try: |
|
return self.logo |
|
except: |
|
return "ECHO_groups" |
|
|
showOverview=DTMLFile('ECHO_content_overview',globals()) |
security.declarePublic('content_html') |
|
def content_html(self): |
|
"""template fuer content""" |
|
return ECHO_basis.content_html(self,'group') |
|
|
|
|
def index_html(self): |
|
"""standard page""" |
|
#print self.objectIDs() |
|
|
|
if 'index.html' in self.__dict__.keys(): |
def manage_addECHO_groupForm(self): |
return getattr(self,'index.html')() |
"""Add group form""" |
elif 'overview' in self.__dict__.keys(): |
pt=zptFile(self, 'zpt/AddECHO_groupForm.zpt') |
return self.showOverview() |
return pt() |
|
|
|
|
pt=PageTemplateFile('Products/ECHO_content/ECHO_content_standard.zpt').__of__(self) |
def manage_addECHO_group(self,id,title,label,description,contentType,responsible,weight,sortfield,coords="",secondaryLinkTitle="",secondaryLink="",credits=None,RESPONSE=None,imageTag="",bgcolour="",logo=""): |
pt.content_type="text/html" |
"""add a echo group""" |
return pt() |
|
|
|
|
|
def getGraphicCoords(self): |
newObj=ECHO_group(id,title,label,description,contentType,responsible,credits,weight,sortfield,coords,secondaryLinkTitle=secondaryLinkTitle,secondaryLink=secondaryLink,imageTag=imageTag,bgcolour="") |
"""Give list of coordinates""" |
|
subColTypes=['ECHO_collection','ECHO_externalLink','ECHO_resource'] |
|
ids=[] |
|
for entry in self.__dict__.keys(): |
|
object=getattr(self,entry) |
|
#print "OB:",object |
|
|
|
try: |
setattr(newObj,'logo',logo) |
print "MT:",object.meta_type |
self._setObject(id,newObj) |
if object.meta_type in subColTypes: |
|
for coord in object.coords: |
|
if len(coord)==4: |
|
ids.append([string.join(coord,", "),object.getId()]) |
|
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
except: |
Globals.InitializeClass(ECHO_group) |
"""nothing""" |
|
print "IDS",ids |
|
return ids |
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: |
|
user = self.getUser(name) |
|
if user is not None and user.authenticate(password, request): |
|
return user |
|
else: |
|
return None |
|
|
def getSubCols(self,sortfield="weight"): |
def domainSpecMatch(self,spec, request): |
|
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) |
|
|
subColTypes=['ECHO_collection','ECHO_externalLink','ECHO_resource'] |
|
ids=[] |
|
for entry in self.__dict__.keys(): |
|
object=getattr(self,entry) |
|
#print "OB:",object |
|
|
|
try: |
|
#print "MT:",object.meta_type |
|
if object.meta_type in subColTypes: |
|
ids.append(object) |
|
|
|
except: |
def manage_addECHO_userFolder(self,dtself=None,REQUEST=None,**ignored): |
"""nothing""" |
"""add a user folder """ |
|
f=ECHO_userFolder() |
|
self=self.this() |
|
try: self._setObject('acl_users', f) |
|
except: return MessageDialog( |
|
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": |
|
|
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) |
|
|
tmplist=[] |
self.REQUEST.RESPONSE.write("<p>Creates:%s</p>\n"%getattr(self,id).absolute_url()) |
for x in ids: |
|
if hasattr(x,sortfield): |
return type,getattr(self,id),urn |
|
|
|
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""" |
|
|
|
meta_type="ECHO_copyrightType" |
|
|
def manage_AddECHO_collectionForm(self): |
def __init__(self,id,title,label,url): |
"""Nothing yet""" |
"""init""" |
pt=PageTemplateFile('Products/ECHO_content/AddECHO_collectionForm.zpt').__of__(self) |
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 |
|
|
def manage_AddECHO_collection(self,context,science,practice,source_type,period,id,title,label,description,content_type,responsible,credits,weight,sortfield,coords,RESPONSE=None): |
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
"""nothing yet""" |
def manage_addECHO_copyrightTypeForm(self): |
scientificClassificationObj=scientificClassification(context,science,practice) |
"""Form for adding a ressource""" |
|
pt=zptFile(self, 'zpt/AddECHO_copyrightTypeForm.zpt') |
|
return pt() |
|
|
scientificInformationObj=scientificInformation(source_type,period) |
|
|
|
|
def manage_addECHO_copyrightType(self,id,title,label,url,RESPONSE=None): |
|
"""addaresource""" |
|
|
newObj=ECHO_collection(id,title,label,description,content_type,responsible,credits,weight,sortfield,coords) |
newObj=ECHO_copyrightType(id,title,label,url) |
|
|
self._setObject(id,newObj) |
self._setObject(id,newObj) |
getattr(self,id)._setObject('scientific_Information',scientificInformationObj) |
|
getattr(self,id).scientific_Information._setObject('scientific_Classification',scientificClassificationObj) |
|
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 __init__(self,id,title): |
|
"""init""" |
|
self.id = 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=zptFile(self, 'zpt/ChangeECHO_linkListTemplate.zpt') |
|
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 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.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 getPartners(self): |
|
"""Get list of Partners. Presently only from a subfolder partners""" |
|
partnerTypes=['ECHO_partner'] |
|
ids=[] |
|
for entry in self.partners.__dict__.keys(): |
|
object=getattr(self.partners,entry) |
|
|
|
try: |
|
|
|
if object.meta_type in partnerTypes: |
|
ids.append(object) |
|
|
|
except: |
def manage_addECHO_linkListForm(self): |
"""nothing""" |
"""Form for adding""" |
return ids |
pt=zptFile(self, 'zpt/AddECHO_linkListTemplate.zpt') |
|
return pt() |
|
|
def getCollectionTree(self): |
|
"""get the collection tree (list of triples (parent,child, depth)""" |
|
|
|
def getCollection(object,depth=0): |
def manage_addECHO_linkList(self, id, label,contentType=0,title=None, text=None, |
depth+=1 |
REQUEST=None, submit=None): |
collections=[] |
"""Add a LinkList with optional file content.""" |
for entry in object.__dict__.keys(): |
|
element=getattr(object,entry) |
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: |
try: |
if element.meta_type=="ECHO_collection": |
u = self.DestinationURL() |
collections.append((object,element,depth)) |
except AttributeError: |
collections+=getCollection(element,depth) |
u = REQUEST['URL1'] |
except: |
|
"""nothing""" |
|
return collections |
|
|
|
|
if submit == " Add and Edit ": |
|
u = "%s/%s" % (u, urllib.quote(id)) |
|
REQUEST.RESPONSE.redirect(u+'/manage_main') |
|
return '' |
|
|
return getCollection(self) |
|
|
|
def getCollectionTreeIds(self): |
class ECHO_support(Folder,ECHO_basis): |
"""Show the IDs of the Tree""" |
"""gefoerdert durch""" |
ret=[] |
meta_type="ECHO_support" |
for collection in self.getCollectionTree(): |
|
ret.append((collection[0].getId(),collection[1].getId(),collection[2])) |
|
return ret |
|
|
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=zptFile(self, 'zpt/ChangeECHO_support') |
|
pt.content_type="text/html" |
|
return pt() |
|
|
def manage_AddECHO_root(self,id,title,RESPONSE=None): |
def ECHO_support_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_supportForm(self): |
pt=PageTemplateFile('Products/ECHO_content/AddECHO_root.zpt').__of__(self) |
"""Form for adding""" |
|
pt=zptFile(self, 'zpt/AddECHO_support.zpt') |
return pt() |
return pt() |
|
|
class ECHO_partner(Image,Persistent): |
def manage_addECHO_support(self, id,institutions=None,RESPONSE=None): |
"""ECHO Partner""" |
"""add the copyright""" |
|
|
meta_type="ECHO_partner" |
meta_type="ECHO_support" |
|
|
|
|
|
self._setObject(id, ECHO_support(id,institutions)) |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
# ECHO - owner of original |
|
class ECHO_ownerOriginal(Folder,ECHO_basis): |
|
"""besitzer des originals""" |
|
meta_type="ECHO_ownerOriginal" |
|
security=ClassSecurityInfo() |
|
|
|
|
|
def __init__(self,id,institutions=None): |
|
"""init""" |
|
self.id=id |
|
self.title='' |
|
self.institutions=toList(institutions) |
|
|
|
security.declarePublic('getOwner') |
|
def getOwner(self): |
|
"""return institutions""" |
|
if self.institutions: |
|
return self.institutions |
|
else: |
|
return [] |
|
|
|
manage_options = Folder.manage_options+( |
|
{'label':'Main Config','action':'ECHO_ownerOriginal_configForm'}, |
|
) |
|
|
|
def ECHO_ownerOriginal_configForm(self): |
|
"""change form""" |
|
pt=zptFile(self, 'zpt/ChangeECHO_ownerOriginal') |
|
pt.content_type="text/html" |
|
return pt() |
|
|
|
def ECHO_ownerOriginal_config(self,institutions=None,RESPONSE=None): |
|
"""change""" |
|
self.institutions=toList(institutions) |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
|
|
def manage_addECHO_ownerOriginalForm(self): |
|
"""Form for adding""" |
|
pt=zptFile(self, 'zpt/AddECHO_ownerOriginal.zpt') |
|
return pt() |
|
|
|
def manage_addECHO_ownerOriginal(self, id,institutions=None,RESPONSE=None): |
|
"""add the copyright""" |
|
|
|
meta_type="ECHO_ownerOriginal" |
|
|
def __init__(self, id, title,url, file, content_type='', precondition=''): |
|
|
self._setObject(id, ECHO_ownerOriginal(id,institutions)) |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
# -------------------------------------------------------------------------------- |
|
|
|
# ECHO - digitized copy by |
|
class ECHO_digiCopyBy(Folder,ECHO_basis): |
|
"""besitzer des originals""" |
|
meta_type="ECHO_digiCopyBy" |
|
security=ClassSecurityInfo() |
|
|
|
|
|
def __init__(self,id,institutions=None): |
|
"""init""" |
|
self.id=id |
|
self.title='' |
|
self.institutions=toList(institutions) |
|
|
|
security.declarePublic('getDigiCopyBy') |
|
def getDigiCopyBy(self): |
|
"""return institutions""" |
|
if self.institutions: |
|
return self.institutions |
|
else: |
|
return [] |
|
|
|
manage_options = Folder.manage_options+( |
|
{'label':'Main Config','action':'ECHO_digiCopyBy_configForm'}, |
|
) |
|
|
|
def ECHO_digiCopyBy_configForm(self): |
|
"""change form""" |
|
pt=zptFile(self, 'zpt/ChangeECHO_digiCopyBy') |
|
pt.content_type="text/html" |
|
return pt() |
|
|
|
def ECHO_digiCopyBy_config(self,institutions=None,RESPONSE=None): |
|
"""change""" |
|
self.institutions=toList(institutions) |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
|
|
def manage_addECHO_digiCopyByForm(self): |
|
"""Form for adding""" |
|
pt=zptFile(self, 'zpt/AddECHO_digiCopyBy.zpt') |
|
return pt() |
|
|
|
def manage_addECHO_digiCopyBy(self, id,institutions=None,RESPONSE=None): |
|
"""add the copyright""" |
|
|
|
meta_type="ECHO_digiCopyBy" |
|
|
|
|
|
self._setObject(id, ECHO_digiCopyBy(id,institutions)) |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
# -------------------------------------------------------------------------------- |
|
|
|
class ECHO_institution(Image,Persistent,ECHO_basis): |
|
"""ECHO Institution""" |
|
|
|
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) |
content_type=self._get_content_type(file, data, id, content_type) |
content_type=self._get_content_type(file, data, id, content_type) |
self.update_data(data, content_type, 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/ChangeECHO_partner.zpt').__of__(self) |
pt=zptFile(self, 'zpt/ChangeECHO_institution.zpt') |
return pt() |
return pt() |
|
|
|
|
manage_AddECHO_partnerForm=DTMLFile('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='', content_type='', |
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 |
""" |
""" |
|
|
Line 718 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,'',content_type, 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. |
Line 733 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') |