version 1.226, 2005/06/20 14:42:19
|
version 1.236, 2005/10/10 19:11:12
|
Line 37 from Products.PageTemplates.PageTemplate
|
Line 37 from Products.PageTemplates.PageTemplate
|
from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate |
from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate |
from Globals import Persistent, package_home |
from Globals import Persistent, package_home |
from Acquisition import Implicit |
from Acquisition import Implicit |
|
from Products.ZCatalog.CatalogPathAwareness import CatalogAware |
|
|
import urllib |
import urllib |
import cgi |
import cgi |
import smtplib |
import smtplib |
import time |
import time |
from Ft.Xml.Domlette import NonvalidatingReader |
from Ft.Xml.Domlette import NonvalidatingReader |
from Ft.Xml.Domlette import PrettyPrint |
from Ft.Xml.Domlette import PrettyPrint, Print |
from Ft.Xml import EMPTY_NAMESPACE |
from Ft.Xml import EMPTY_NAMESPACE |
|
|
import Ft.Xml.XPath |
import Ft.Xml.XPath |
Line 87 def setECHO_collectionInformation(self,t
|
Line 88 def setECHO_collectionInformation(self,t
|
self.credits=toList(credits) |
self.credits=toList(credits) |
self.weight=weight |
self.weight=weight |
|
|
|
class ECHO_locale(ZopePageTemplate): |
|
"""localisierung""" |
|
|
|
meta_type="ECHO_locale" |
|
|
|
def __init__(self,id,lang,title,label,text=None,content_type=None): |
|
self.lang=lang |
|
self.title=title |
|
self.label=label |
|
if text: |
|
self.pt_edit(text, content_type) |
|
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 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: |
|
self.pt_edit(text, content_type) |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
|
|
def manage_addECHO_localeForm(self): |
|
"""Form for adding""" |
|
pt=zptFile(self, 'zpt/AddECHO_localeForm.zpt') |
|
return pt() |
|
|
|
def manage_addECHO_locale(self,lang,title,label,text=None,content_type=None,RESPONSE=None): |
|
"""add echo locale""" |
|
|
|
id="locale_"+lang |
|
|
|
self._setObject(id, ECHO_locale(id,lang,title,label,text,content_type)) |
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
|
class ECHO_copyright(Folder,ECHO_basis): |
class ECHO_copyright(Folder,ECHO_basis): |
"""Copyright informationen""" |
"""Copyright informationen""" |
Line 254 def manage_addECHO_fullText(self, id, ti
|
Line 303 def manage_addECHO_fullText(self, id, ti
|
return '' |
return '' |
|
|
|
|
class ECHO_resource(Folder,Persistent,ECHO_basis): |
class ECHO_resource(CatalogAware,Folder,Persistent,ECHO_basis): |
"""ECHO Ressource""" |
"""ECHO Ressource""" |
security=ClassSecurityInfo() |
security=ClassSecurityInfo() |
meta_type='ECHO_resource' |
meta_type='ECHO_resource' |
|
default_catalog='resourceCatalog' |
|
|
# viewClassificationList=viewClassificationListMaster |
# viewClassificationList=viewClassificationListMaster |
|
|
|
def PrincipiaSearchSource(self): |
|
"""Return cataloguable key for ourselves.""" |
|
return str(self) |
|
|
getSubCols = ECHO_helpers.getSubCols |
getSubCols = ECHO_helpers.getSubCols |
|
|
|
def reindex(self): |
|
"""generate fields for indexing and reindex""" |
|
import urlparse |
|
#TODO: korrigieren des metalink pfades konfigurierbar machen |
|
splitted= [x for x in urlparse.urlparse(self.metalink)] |
|
splitted[1]="foxridge.mpiwg-berlin.mpg.de"[0:] |
|
|
|
if splitted[0]=="http": |
|
self.metalink=urlparse.urlunparse(splitted) |
|
|
|
|
|
self.fullTextUrl=self.getFullTextXML(noredirect="yes") |
|
|
|
#TODO: korrigieren relative url to absoluter url volltexten, konfigurierbar? |
|
splitted= [x for x in urlparse.urlparse(self.fullTextUrl)] |
|
if splitted[0]=="": |
|
splitted[0]="http" |
|
splitted[1]="foxridge.mpiwg-berlin.mpg.de"[0:] |
|
|
|
self.fullTextUrl=urlparse.urlunparse(splitted) |
|
|
|
self.imagePath=self.getImagePath() |
|
|
|
self.reindex_object() |
|
|
|
|
security.declareProtected('View','createPDF') |
security.declareProtected('View','createPDF') |
def createPDF(self,RESPONSE=None,local=None,dpi=150): |
def createPDF(self,RESPONSE=None,local=None,dpi=150): |
Line 985 class ECHO_resource(Folder,Persistent,EC
|
Line 1064 class ECHO_resource(Folder,Persistent,EC
|
return writeMetadata(self.metalink,self.metaDataHash,project,startpage,xslt,thumbtemplate,topbar,digiLibTemplate,digiliburlprefix=digiliburlprefix) |
return writeMetadata(self.metalink,self.metaDataHash,project,startpage,xslt,thumbtemplate,topbar,digiLibTemplate,digiliburlprefix=digiliburlprefix) |
|
|
def showMetaDataXML(self,project=None,startpage=None,xslt=None,thumbtemplate=None,topbar=None,digiLibTemplate=None): |
def showMetaDataXML(self,project=None,startpage=None,xslt=None,thumbtemplate=None,topbar=None,digiLibTemplate=None): |
"""schreibe md""" |
"""return bibliographical metadata as stored in the object""" |
|
|
try: |
try: |
|
|
Line 993 class ECHO_resource(Folder,Persistent,EC
|
Line 1072 class ECHO_resource(Folder,Persistent,EC
|
except: |
except: |
return "<error> no metadata stored</error>" |
return "<error> no metadata stored</error>" |
|
|
|
def getXQueryMetaData(self,xquery): |
|
''' |
|
execute an xquery on the metadata and returns a list of tuples, |
|
each tuple represent the content of the node as text and the whole node as xml-fragment |
|
@param xquery: xquery auf den metadaten |
|
''' |
|
|
|
try: |
|
md=writeMetadata(self.metalink,self.metaDataHash,xmlfrag="yes") |
|
except: |
|
return None |
|
|
|
dom = NonvalidatingReader.parseString(md,"http://www.mpiwg-berlin.mpg.de/") |
|
|
|
results=Ft.Xml.XPath.Evaluate(xquery, contextNode=dom) |
|
|
|
ret=[] |
|
for result in results: |
|
|
|
buf = cStringIO.StringIO() |
|
PrettyPrint(result, stream=buf) |
|
str = buf.getvalue()[0:] |
|
buf.close() |
|
ret.append((getTextFromNode(result),str)) |
|
|
|
return ret |
|
|
def getMetaDataXML(self,project=None,startpage=None,xslt=None,thumbtemplate=None,topbar=None,digiLibTemplate=None): |
def getMetaDataXML(self,project=None,startpage=None,xslt=None,thumbtemplate=None,topbar=None,digiLibTemplate=None): |
"""prints out metadata as stored in the echo environment, format is the index.meta format""" |
"""prints out metadata as stored in the echo environment, format is the index.meta format""" |
self.REQUEST.RESPONSE.setHeader('Content-Type','text/xml') |
self.REQUEST.RESPONSE.setHeader('Content-Type','text/xml') |
Line 1409 class ECHO_link(ECHO_externalLink):
|
Line 1515 class ECHO_link(ECHO_externalLink):
|
|
|
def index_html(self): |
def index_html(self): |
"""standard link""" |
"""standard link""" |
|
if self.link: |
splitted=self.link.split("?") |
splitted=self.link.split("?") |
if len(splitted)>1: |
if len(splitted)>1: |
params=cgi.parse_qs(splitted[1]) |
params=cgi.parse_qs(splitted[1]) |
Line 1423 class ECHO_link(ECHO_externalLink):
|
Line 1529 class ECHO_link(ECHO_externalLink):
|
params={} |
params={} |
|
|
params['backLink']=self.aq_parent.absolute_url() |
params['backLink']=self.aq_parent.absolute_url() |
|
params['startLink']=splitted[0]+"?"+urllib.urlencode(params) |
|
|
|
|
return self.REQUEST.RESPONSE.redirect(splitted[0]+"?"+urllib.urlencode(params)) |
return self.REQUEST.RESPONSE.redirect(splitted[0]+"?"+urllib.urlencode(params)) |
|
else: |
|
return "" |
|
|
def manage_addECHO_linkForm(self): |
def manage_addECHO_linkForm(self): |
"""Form for external Links""" |
"""Form for external Links""" |
Line 1454 class ECHO_collection(Folder, Persistent
|
Line 1563 class ECHO_collection(Folder, Persistent
|
|
|
path="/mpiwg/online/permanent/shipbuilding" |
path="/mpiwg/online/permanent/shipbuilding" |
|
|
|
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],None) |
|
else: |
|
obj.pt_edit(REQUEST.form[key],None) |
|
else: |
|
text=obj.ZopeFind(obj,obj_metatypes=['ECHO_mapText']) |
|
if splitted[1]=="en": |
|
|
|
text[0][1].locale_en.pt_edit(REQUEST.form[key],None) |
|
else: |
|
text[0][1].pt_edit(REQUEST.form[key],None) |
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
|
def getRDF(self,urn=None): |
def getRDF(self,urn=None): |
"""rdf of the collection""" |
"""rdf of the collection""" |
|
|
Line 1814 class ECHO_collection(Folder, Persistent
|
Line 1980 class ECHO_collection(Folder, Persistent
|
|
|
def addMovie(self,id,title,label,description,contentType,responsible,link,thumbUrl,rawFile,lowresFile,metalink,weight,credits=None,coords=None,RESPONSE=None): |
def addMovie(self,id,title,label,description,contentType,responsible,link,thumbUrl,rawFile,lowresFile,metalink,weight,credits=None,coords=None,RESPONSE=None): |
"""SSS""" |
"""SSS""" |
print "we are here" |
|
#manage_addECHO_movie(self,id,title,label,description,responsible,link,thumbUrl,rawFile,metalink,weight,credits=None,coords=None,RESPONSE=None) |
#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): |
if not hasattr(self,id): |
try: |
try: |
Line 1948 class ECHO_collection(Folder, Persistent
|
Line 2114 class ECHO_collection(Folder, Persistent
|
{'label':'Main Config','action':'ECHO_collection_config'}, |
{'label':'Main Config','action':'ECHO_collection_config'}, |
{'label':'Change Labels','action':'changeLabels'}, |
{'label':'Change Labels','action':'changeLabels'}, |
{'label':'Change Titles','action':'changeTitles'}, |
{'label':'Change Titles','action':'changeTitles'}, |
|
{'label':'Localize','action':'localizeObjects'}, |
{'label':'Change Weights','action':'changeWeights'}, |
{'label':'Change Weights','action':'changeWeights'}, |
{'label':'Rerender Labels and Titles','action':'ECHO_rerenderLinksMDWarning'}, |
{'label':'Rerender Labels and Titles','action':'ECHO_rerenderLinksMDWarning'}, |
{'label':'Graphic Coords','action':'ECHO_graphicEntry'}, |
{'label':'Graphic Coords','action':'ECHO_graphicEntry'}, |
Line 1983 class ECHO_collection(Folder, Persistent
|
Line 2150 class ECHO_collection(Folder, Persistent
|
|
|
|
|
security.declarePublic('changeECHO_collection') |
security.declarePublic('changeECHO_collection') |
def changeECHO_collection(self,title,label,description,contentType,responsible,weight,secondaryLink,secondaryLinkTitle,credits=None,sortfield="weight",coords=None,RESPONSE=None,imageTag="",bgcolour="",location=None,isAlwaysClickable=None): |
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=""): |
"""Aenderung der Properties""" |
"""Aenderung der Properties""" |
|
|
self.secondaryLink=secondaryLink |
self.secondaryLink=secondaryLink |
Line 1992 class ECHO_collection(Folder, Persistent
|
Line 2159 class ECHO_collection(Folder, Persistent
|
self.bgcolour=bgcolour |
self.bgcolour=bgcolour |
self.location=location |
self.location=location |
self.isAlwaysClickable=isAlwaysClickable |
self.isAlwaysClickable=isAlwaysClickable |
|
self.prefix=prefix[0:] |
|
self.suffix=suffix[0:] |
|
|
setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight) |
setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight) |
|
|
Line 2407 class ECHO_root(Folder,Persistent,Implic
|
Line 2576 class ECHO_root(Folder,Persistent,Implic
|
|
|
meta_type="ECHO_root" |
meta_type="ECHO_root" |
|
|
|
def findObjectFromFulltext(self,url=None,existUri=None): |
|
''' |
|
|
|
@param url: |
|
@param existUri: |
|
''' |
|
#TODO: at the moment assume that the filename is unique, the whole has to changed to a system of ids. |
|
return None |
|
|
|
def reindex(self,RESPONSE=None): |
|
"""indiziere alle Objecte neu""" |
|
|
|
if RESPONSE: |
|
RESPONSE.write("<html><body>") |
|
|
|
resources=self.ZopeFind(self,obj_metatypes=["ECHO_resource"], search_sub=1) |
|
|
|
for resource in resources: |
|
resource[1].reindex() |
|
print "<p> done %s </p>\n" |
|
if RESPONSE: |
|
RESPONSE.write("<p> done %s </p>\n"%resource[0]) |
|
|
|
if RESPONSE: |
|
RESPONSE.write("<p> ok </p></html></body>\n") |
|
|
def printer(self,txt): |
def printer(self,txt): |
print txt |
print txt |
print txt[2] |
print txt[2] |
Line 2421 class ECHO_root(Folder,Persistent,Implic
|
Line 2616 class ECHO_root(Folder,Persistent,Implic
|
def item2(self,txt): |
def item2(self,txt): |
return txt[2] |
return txt[2] |
|
|
|
def setLanguage(self,lang): |
|
"""Set language cookie""" |
|
self.REQUEST.RESPONSE.setCookie('lang_exhibition',lang,path="/") |
|
|
|
def switchLanguage(self): |
|
"""Set language cookie""" |
|
if self.getLanguage()=="en": |
|
lang="de" |
|
else: |
|
lang="en" |
|
|
|
self.REQUEST.RESPONSE.setCookie('lang_exhibition',lang,path="/") |
|
self.REQUEST.RESPONSE.redirect(self.REQUEST['URL1']) |
|
def getLanguage(self): |
|
"""get language cookie""" |
|
lang= self.REQUEST.cookies.get('lang_exhibition','de') |
|
if lang == '': |
|
lang="de" |
|
return lang |
|
|
def getContentOverviewTemplate(self): |
def getContentOverviewTemplate(self): |
"""produces overview template with macro""" |
"""produces overview template with macro""" |
pt = zptObjectOrFile(self, 'content_overview_template') |
pt = zptObjectOrFile(self, 'content_overview_template') |
Line 2989 class ECHO_root(Folder,Persistent,Implic
|
Line 3204 class ECHO_root(Folder,Persistent,Implic
|
|
|
#str= dom.toxml('utf-8') |
#str= dom.toxml('utf-8') |
buf = cStringIO.StringIO() |
buf = cStringIO.StringIO() |
PrettyPrint(dom, stream=buf, encoding='UTF-8') |
PrettyPrint(dom, stream=buf) |
str = buf.getvalue() |
str = buf.getvalue() |
buf.close() |
buf.close() |
#str=PrettyPrint(dom.documentElement,encoding='UTF-8') |
#str=PrettyPrint(dom.documentElement,encoding='UTF-8') |
#print link.toxml('utf-8') |
#print link.toxml('utf-8') |
#print type(str) |
#print type(str) |
retStr=regexpPage.search(str) |
retStr=regexpPage.search(str) |
|
|
try: # hack warum fehtl manchmal page?? |
try: # hack warum fehtl manchmal page?? |
return retStr.group(1) |
return retStr.group(1) |
except: |
except: |
Line 3012 class ECHO_root(Folder,Persistent,Implic
|
Line 3228 class ECHO_root(Folder,Persistent,Implic
|
except: |
except: |
"""nothing""" |
"""nothing""" |
|
|
dbs={'vl_technology':'','vl_people':'','vl_sites':''} |
dbs={'vl_technology':'','vl_people':" AND complete='yes'",'vl_sites':''} |
res=None |
res=None |
for db in dbs.keys(): |
for db in dbs.keys(): |
res=res or self.search(var=str("select reference from %s where reference =\'%s\' %s"%(db,ref,dbs[db]))) |
res=res or self.search(var=str("select reference from %s where reference =\'%s\' %s"%(db,ref,dbs[db]))) |