version 1.182, 2004/10/27 14:23:24
|
version 1.188, 2004/11/10 16:32:11
|
Line 29 from Products.PageTemplates.PageTemplate
|
Line 29 from Products.PageTemplates.PageTemplate
|
from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate |
from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate |
from Globals import Persistent, package_home |
from Globals import Persistent, package_home |
from Acquisition import Implicit |
from Acquisition import Implicit |
from ECHO_helpers import displayTypes, getText,readFieldFromXML |
from ECHO_helpers import * |
import urllib |
import urllib |
import smtplib |
import smtplib |
import time |
import time |
Line 263 def content_html(self,type):
|
Line 263 def content_html(self,type):
|
pt.content_type="text/html" |
pt.content_type="text/html" |
return pt() |
return pt() |
|
|
def toList(field): |
|
"""Einzelfeld in Liste umwandeln""" |
|
if type(field)==StringType: |
|
return [field] |
|
else: |
|
return field |
|
|
|
|
|
|
|
Line 305 class BrowserCheck:
|
Line 299 class BrowserCheck:
|
"""check the browsers request to find out the browser type""" |
"""check the browsers request to find out the browser type""" |
|
|
def __init__(self, zope): |
def __init__(self, zope): |
|
"""initialisiere""" |
self.ua = zope.REQUEST.get_header("HTTP_USER_AGENT") |
self.ua = zope.REQUEST.get_header("HTTP_USER_AGENT") |
self.isN4 = (string.find(self.ua, 'Mozilla/4.') > -1) and (string.find(self.ua, 'MSIE') < 0) |
self.isN4 = (string.find(self.ua, 'Mozilla/4.') > -1) and (string.find(self.ua, 'MSIE') < 0) |
self.isIE = string.find(self.ua, 'MSIE') > -1 |
self.isIE = string.find(self.ua, 'MSIE') > -1 |
Line 317 class BrowserCheck:
|
Line 312 class BrowserCheck:
|
self.isIEWin = self.isIE and self.isWin |
self.isIEWin = self.isIE and self.isWin |
self.isIEMac = self.isIE and self.isMac |
self.isIEMac = self.isIE and self.isMac |
|
|
|
class Hello(Folder): |
|
"""helloo""" |
|
def __init__(self): |
|
self.test=test |
|
|
|
meta_type="ECHO_copyright" |
|
|
|
|
|
|
|
def __init__(self,id,title,copyrights): |
|
"""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=PageTemplateFile('Products/ECHO_content/zpt/ChangeECHO_copyright').__of__(self) |
|
pt.content_type="text/html" |
|
return pt() |
|
|
|
def ECHO_copyright_config(self,title,RESPONSE=None): |
|
"""change""" |
|
self.title=title |
|
self.copyrights=[] |
|
self.copyrights=getCopyrightsFromForm(self,self.REQUEST.form)[0:] |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
|
|
|
Line 1011 class ECHO_resource(Folder,Persistent):
|
Line 1044 class ECHO_resource(Folder,Persistent):
|
def createImageUrl(self,pn=1): |
def createImageUrl(self,pn=1): |
"""create ImageUrl""" |
"""create ImageUrl""" |
|
|
resourcepath=readFieldFromXML(self.metalink,'resource','archive-path').replace('/mpiwg/online','') |
|
|
resourcepath=readFieldFromXML(self.metalink,'resource','archive-path') |
|
|
digiliburlprefix=readFieldFromXML(self.metalink,'texttool','digiliburlprefix') |
digiliburlprefix=readFieldFromXML(self.metalink,'texttool','digiliburlprefix') |
images=readFieldFromXML(self.metalink,'texttool','image') |
images=readFieldFromXML(self.metalink,'texttool','image') |
|
|
|
|
|
if (not resourcepath) or (not digiliburlprefix) or (not images): |
|
zLOG.LOG("ECHO (createImageUrl)",zLOG.ERROR,"Cannot create ImageUrl for %s"%self.absolute_url()) |
|
return None |
|
resourcepath=resourcepath.replace('/mpiwg/online','') |
if not digiliburlprefix: digiliburlprefix="http://echo.mpiwg-berlin.mpg.de/zogilib?" |
if not digiliburlprefix: digiliburlprefix="http://echo.mpiwg-berlin.mpg.de/zogilib?" |
|
|
if (not images) or (not resourcepath): return None |
if (not images) or (not resourcepath): return None |
|
|
return "%sfn=%s&pn=%i"%(digiliburlprefix,resourcepath+"/"+images,pn) |
return "%sfn=%s&pn=%i"%(digiliburlprefix,resourcepath+"/"+images,pn) |
|
|
def copyTitleToInfoXML(self): |
def copyTitleToInfoXML(self,RESPONSE=None): |
"""copy title from the resource""" |
"""copy title from the resource""" |
presentationXML=readFieldFromXML(self.metalink,'texttool','presentation') |
presentationXML=readFieldFromXML(self.metalink,'texttool','presentation') |
resourcepath=readFieldFromXML(self.metalink,'resource','archive-path') |
resourcepath=readFieldFromXML(self.metalink,'resource','archive-path') |
print os.path.join(resourcepath,presentationXML) |
if (not presentationXML) or (not resourcepath): |
|
if RESPONSE: |
|
RESPONSE.write("Error: %s\n"%self.getId()) |
|
else: |
|
return None,self.absolute_url() |
|
|
|
try: |
fh=file(os.path.join(resourcepath,presentationXML),'w') |
fh=file(os.path.join(resourcepath,presentationXML),'w') |
fh.write("""<info> |
fh.write("""<info> |
<author></author> |
<author></author> |
Line 1035 class ECHO_resource(Folder,Persistent):
|
Line 1080 class ECHO_resource(Folder,Persistent):
|
<display>yes</display> |
<display>yes</display> |
</info>"""%self.title) |
</info>"""%self.title) |
fh.close() |
fh.close() |
|
return 1,self.getId() |
|
except: |
|
if RESPONSE: |
|
RESPONSE.write("Error: %s\n"%self.getId()) |
|
else: |
|
return None,self.absolute_url() |
|
|
|
|
def setStartPage(self,startpage=None,RESPONSE=None): |
def setStartPage(self,startpage=None,RESPONSE=None): |
Line 1177 class ECHO_resource(Folder,Persistent):
|
Line 1228 class ECHO_resource(Folder,Persistent):
|
"""getFullTextXML; gives the FullText as an XML Document, and <error></error> if somthing goes wrong.""" |
"""getFullTextXML; gives the FullText as an XML Document, and <error></error> if somthing goes wrong.""" |
|
|
try: |
try: |
zLOG.LOG("ECHO Fulltext",zLOG.INFO,"open %s"%self.metalink) |
#zLOG.LOG("ECHO Fulltext",zLOG.INFO,"open %s"%self.metalink) |
fh=ECHO_helpers.urlopen(self.metalink) |
fh=ECHO_helpers.urlopen(self.metalink) |
zLOG.LOG("ECHO Fulltext",zLOG.INFO,"opened %s"%self.metalink) |
#zLOG.LOG("ECHO Fulltext",zLOG.INFO,"opened %s"%self.metalink) |
dom=xml.dom.minidom.parse(fh) |
dom=xml.dom.minidom.parse(fh) |
texttools=dom.getElementsByTagName('texttool') |
texttools=dom.getElementsByTagName('texttool') |
text=texttools[0].getElementsByTagName('text') |
text=texttools[0].getElementsByTagName('text') |
texturl=getText(text[0].childNodes) |
texturl=getText(text[0].childNodes) |
|
|
zLOG.LOG("ECHO Fulltext",zLOG.INFO,"found %s"%texturl) |
#zLOG.LOG("ECHO Fulltext",zLOG.INFO,"found %s"%texturl) |
fh.close() |
fh.close() |
zLOG.LOG("ECHO Fulltext",zLOG.INFO,"closed fh") |
#zLOG.LOG("ECHO Fulltext",zLOG.INFO,"closed fh") |
#keine url |
#keine url |
if not (texturl.split(":")[0] in ['http','ftp','file']): |
if not (texturl.split(":")[0] in ['http','ftp','file']): |
if not noredirect: |
if not noredirect: |
Line 2213 class ECHO_collection(Folder, Persistent
|
Line 2264 class ECHO_collection(Folder, Persistent
|
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
def copyTitleToInfoXMLFolder(self): |
def copyTitleToInfoXMLFolder(self,RESPONSE=None): |
"""copy title into the title field of info.xml |
"""copy title into the title field of info.xml |
author and date werden leer!!! |
author and date werden leer!!! |
""" |
""" |
|
|
|
|
resources=self.ZopeFind(self,obj_metatypes=['ECHO_resource'],search_sub=1) |
resources=self.ZopeFind(self,obj_metatypes=['ECHO_resource'],search_sub=1) |
|
|
for resource in resources: |
|
|
|
resource[1].copyTitleToInfoXML() |
for resource in resources: |
|
ret,txt=resource[1].copyTitleToInfoXML() |
|
if (not ret) and RESPONSE: |
|
RESPONSE.write("error: %s\n"%txt) |
|
if ret and RESPONSE: |
|
RESPONSE.write("ok: %s\n"%txt) |
|
|
|
#zLOG.LOG("ECHO (copyTitleToInfoXMLFolder)",zLOG.INFO,txt) |
if RESPONSE is not None: |
if RESPONSE is not None: |
|
RESPONSE.write("done!\n") |
|
RESPONSE.close() |
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
def copySearchFields(self,RESPONSE=None): |
def copySearchFields(self,RESPONSE=None): |
Line 3083 class ECHO_root(Folder,Persistent,Implic
|
Line 3142 class ECHO_root(Folder,Persistent,Implic
|
#return "http://enlil.museum.upenn.edu/cgi-bin/cdlget.plx?item=%s&project=ncdl" |
#return "http://enlil.museum.upenn.edu/cgi-bin/cdlget.plx?item=%s&project=ncdl" |
###END CDLI add |
###END CDLI add |
|
|
|
|
|
def checkResource(self,id): |
|
"""checks if a resource is in the tree, gives back none or list of resources""" |
|
if hasattr(self,"_v_checkResource") and self._v_checkResource.has_key(id): #existiert ein cache und id ist bereits drin? |
|
return self._v_checkResource[id] |
|
|
|
else: |
|
resources=self.ZopeFind(self,obj_metatypes=['ECHO_resource'],obj_ids=[id],search_sub=1) |
|
|
|
if not hasattr(self,"_v_checkResource"): self._v_checkResource={}#lege cache an falls nicht existent |
|
if resources: |
|
self._v_checkResource[id]=resources[0:] # slicing to be sure that data is stabil |
|
else: |
|
self._v_checkResource[id]=None |
|
|
|
return self._v_checkResource[id] |
|
|
def sendForm(self,fromaddr,content,server='mail.mpiwg-berlin.mpg.de'): |
def sendForm(self,fromaddr,content,server='mail.mpiwg-berlin.mpg.de'): |
"""sendform""" |
"""sendform""" |
toaddrs=["dwinter@mpiwg-berlin.mpg.de"] |
toaddrs=["dwinter@mpiwg-berlin.mpg.de"] |
Line 3581 class ECHO_root(Folder,Persistent,Implic
|
Line 3657 class ECHO_root(Folder,Persistent,Implic
|
|
|
if self.checkRef(ref): |
if self.checkRef(ref): |
if pn: |
if pn: |
link.setAttribute("href",self.aq_parent.absolute_url()+"/vlp_coll?id="+ref+"&p="+pn) |
link.setAttribute("href",self.aq_parent.absolute_url()+"/references?id="+ref+"&p="+pn) |
else: |
else: |
link.setAttribute("href",self.aq_parent.absolute_url()+"/vlp_coll?id="+ref) |
link.setAttribute("href",self.aq_parent.absolute_url()+"/references?id="+ref) |
|
|
|
|
newxml=dom.toxml('utf-8') |
newxml=dom.toxml('utf-8') |
Line 4224 def manage_addECHO_institution(self, id,
|
Line 4300 def manage_addECHO_institution(self, id,
|
except: url=REQUEST['URL1'] |
except: url=REQUEST['URL1'] |
REQUEST.RESPONSE.redirect('%s/manage_main' % url) |
REQUEST.RESPONSE.redirect('%s/manage_main' % url) |
return id |
return id |
|
|