version 1.47.2.101, 2008/09/04 17:51:51
|
version 1.47.2.111, 2009/12/15 13:16:47
|
Line 13 from Globals import package_home
|
Line 13 from Globals import package_home
|
import urllib |
import urllib |
import re |
import re |
import os |
import os |
|
import email |
from types import * |
from types import * |
import logging |
import logging |
import xmlhelper # Methoden zur Verwaltung der projekt xml |
import xmlhelper # Methoden zur Verwaltung der projekt xml |
Line 20 from OFS.SimpleItem import SimpleItem
|
Line 21 from OFS.SimpleItem import SimpleItem
|
from OFS.Folder import Folder |
from OFS.Folder import Folder |
from OFS.Image import Image |
from OFS.Image import Image |
from AccessControl import ClassSecurityInfo |
from AccessControl import ClassSecurityInfo |
|
from AccessControl import getSecurityManager |
from bibliography import * |
from bibliography import * |
import time |
import time |
|
from OFS.Cache import Cacheable |
#import xml.dom.minidom |
#import xml.dom.minidom |
import sys |
import sys |
#from Ft.Xml.XPath import Evaluate |
#from Ft.Xml.XPath import Evaluate |
Line 55 class MPIWGProject_publication(Folder):
|
Line 58 class MPIWGProject_publication(Folder):
|
"""publications object fuer project""" |
"""publications object fuer project""" |
|
|
meta_type="MPIWGProject_publication" |
meta_type="MPIWGProject_publication" |
|
def redirect(self,RESPONSE,url): |
|
"""mache ein redirect mit einem angehaengten time stamp um ein reload zu erzwingen""" |
|
|
|
timeStamp=time.time() |
|
|
|
if url.find("?")>-1: #giebt es schon parameter |
|
addStr="&time=%s" |
|
else: |
|
addStr="?time=%s" |
|
|
|
RESPONSE.setHeader('Last-Modified',email.Utils.formatdate().split("-")[0]+'GMT') |
|
logging.debug(email.Utils.formatdate()+' GMT') |
|
RESPONSE.redirect(url+addStr%timeStamp) |
|
|
def editPublication(self,text=None,image1=None,image2=None,description=None,RESPONSE=None): |
def editPublication(self,text=None,image1=None,image2=None,description=None,RESPONSE=None): |
"""edit a publication""" |
"""edit a publication""" |
Line 83 class MPIWGProject_publication(Folder):
|
Line 99 class MPIWGProject_publication(Folder):
|
|
|
|
|
if RESPONSE: |
if RESPONSE: |
RESPONSE.redirect("../managePublications") |
self.redirect(RESPONSE,"../managePublications") |
|
|
class MPIWGProject_image(Image): |
class MPIWGProject_image(Image): |
"""Images for Projects""" |
"""Images for Projects""" |
Line 109 class MPIWGProject_image(Image):
|
Line 125 class MPIWGProject_image(Image):
|
self.caption=caption[0:] |
self.caption=caption[0:] |
|
|
if RESPONSE: |
if RESPONSE: |
RESPONSE.redirect("../manageImages") |
|
|
|
class MPIWGProject(CatalogAware,Folder): |
self.redirect(RESPONSE,"../manageImages") |
|
|
|
class MPIWGProject(CatalogAware,Folder,Cacheable): |
"""Class for Projects""" |
"""Class for Projects""" |
|
|
|
def _p_resolveConflict(self, oldState, savedState, newState): |
|
return newState |
|
|
security=ClassSecurityInfo() |
security=ClassSecurityInfo() |
meta_type='MPIWGProject' |
meta_type='MPIWGProject' |
default_catalog='ProjectCatalog' |
default_catalog='ProjectCatalog' |
|
def redirect(self,RESPONSE,url): |
|
"""mache ein redirect mit einem angehaengten time stamp um ein reload zu erzwingen""" |
|
|
|
timeStamp=time.time() |
|
|
|
if url.find("?")>-1: #giebt es schon parameter |
|
addStr="&time=%s" |
|
else: |
|
addStr="?time=%s" |
|
|
|
RESPONSE.setHeader('Last-Modified',email.Utils.formatdate().split("-")[0]+'GMT') |
|
logging.debug(email.Utils.formatdate()+' GMT') |
|
RESPONSE.redirect(url+addStr%timeStamp) |
|
|
def decode(self,str): |
def decode(self,str): |
"""return unicode object""" |
"""return unicode object""" |
Line 147 class MPIWGProject(CatalogAware,Folder):
|
Line 179 class MPIWGProject(CatalogAware,Folder):
|
self.addPublication(pubSplit) |
self.addPublication(pubSplit) |
|
|
if RESPONSE: |
if RESPONSE: |
RESPONSE.redirect('managePublications') |
|
|
self.redirect(RESPONSE,'managePublications') |
|
|
|
|
def copyImageToMargin(self,RESPONSE=None): |
def copyImageToMargin(self,RESPONSE=None): |
Line 216 class MPIWGProject(CatalogAware,Folder):
|
Line 249 class MPIWGProject(CatalogAware,Folder):
|
obj.update_data(data) |
obj.update_data(data) |
|
|
if RESPONSE: |
if RESPONSE: |
RESPONSE.redirect('manageImages') |
|
|
self.redirect(RESPONSE,'manageImages') |
|
|
def manageImages(self,imageName=None,op=None): |
def manageImages(self,imageName=None,op=None): |
"""managage images""" |
"""managage images""" |
Line 295 class MPIWGProject(CatalogAware,Folder):
|
Line 329 class MPIWGProject(CatalogAware,Folder):
|
|
|
|
|
if RESPONSE: |
if RESPONSE: |
RESPONSE.redirect("managePublications") |
self.redirect(RESPONSE,"managePublications") |
|
|
|
|
def getPublications(self): |
def getPublications(self): |
"""get all Publications""" |
"""get all Publications""" |
Line 322 class MPIWGProject(CatalogAware,Folder):
|
Line 357 class MPIWGProject(CatalogAware,Folder):
|
obj.id=name |
obj.id=name |
|
|
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('managePublications') |
|
|
self.redirect(RESPONSE,'managePublications') |
|
|
|
|
def getLastPublicationNumber(self): |
def getLastPublicationNumber(self): |
Line 337 class MPIWGProject(CatalogAware,Folder):
|
Line 373 class MPIWGProject(CatalogAware,Folder):
|
"""delete Publication id""" |
"""delete Publication id""" |
self.manage_delObjects([id]) |
self.manage_delObjects([id]) |
if RESPONSE: |
if RESPONSE: |
RESPONSE.redirect('managePublications') |
|
|
self.redirect(RESPONSE,'managePublications') |
|
|
def getImages(self): |
def getImages(self): |
"""get all Images""" |
"""get all Images""" |
Line 374 class MPIWGProject(CatalogAware,Folder):
|
Line 411 class MPIWGProject(CatalogAware,Folder):
|
except: |
except: |
logging.error("ERROR MPIWG: %s %s"%sys.exc_info()[0:2]) |
logging.error("ERROR MPIWG: %s %s"%sys.exc_info()[0:2]) |
if RESPONSE: |
if RESPONSE: |
RESPONSE.redirect('manageImages') |
self.redirect(RESPONSE,'manageImages') |
|
|
|
|
|
|
def hasChildren(self,date=None,onlyActive=1,onlyArchived=1): |
def hasChildren(self,date=None,onlyActive=1,onlyArchived=1): |
"""check if project has children""" |
"""check if project has children""" |
|
|
ct=self.getContexts(childs=self.getContent('xdata_05'), |
ct=self.getContexts(childs=self.getContent('xdata_05'), |
depth=1,date=date,onlyActive=onlyActive) |
depth=1,date=date,onlyActive=onlyActive) |
|
|
Line 407 class MPIWGProject(CatalogAware,Folder):
|
Line 446 class MPIWGProject(CatalogAware,Folder):
|
obj.id=filename |
obj.id=filename |
|
|
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('manageImages') |
|
|
self.redirect(RESPONSE,'manageImages') |
|
|
def PrincipiaSearchSource(self): |
def PrincipiaSearchSource(self): |
"""Return cataloguable key for ourselves.""" |
"""Return cataloguable key for ourselves.""" |
Line 492 class MPIWGProject(CatalogAware,Folder):
|
Line 532 class MPIWGProject(CatalogAware,Folder):
|
"""set Archive Time""" |
"""set Archive Time""" |
self.archiveTime=time[0:] |
self.archiveTime=time[0:] |
|
|
|
def delArchiveTime(self): |
|
"""delete archive time""" |
|
del self.archiveTime |
|
|
def versionManageForm(self): |
def versionManageForm(self): |
"""version Manage form:currently only set to invisible""" |
"""version Manage form:currently only set to invisible""" |
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','MPIWGProject_versionManageForm.zpt')).__of__(self) |
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','MPIWGProject_versionManageForm.zpt')).__of__(self) |
Line 502 class MPIWGProject(CatalogAware,Folder):
|
Line 546 class MPIWGProject(CatalogAware,Folder):
|
self.invisible=invisible |
self.invisible=invisible |
|
|
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('manage_main') |
|
|
self.redirect(RESPONSE,'manage_main') |
|
|
|
|
def crossLinker(self): |
def crossLinker(self): |
Line 538 class MPIWGProject(CatalogAware,Folder):
|
Line 583 class MPIWGProject(CatalogAware,Folder):
|
self._setObject(id,newObj) |
self._setObject(id,newObj) |
#self.manage_addPageTemplate(id,title) |
#self.manage_addPageTemplate(id,title) |
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('manage_main') |
self.redirect(RESPONSE,'manage_main') |
|
|
def __init__(self, id, argv=None): |
def __init__(self, id, argv=None): |
"""initiere classe""" |
"""initiere classe""" |
Line 576 class MPIWGProject(CatalogAware,Folder):
|
Line 621 class MPIWGProject(CatalogAware,Folder):
|
def isArchivedProject(self): |
def isArchivedProject(self): |
"""check if the project is archived""" |
"""check if the project is archived""" |
|
|
completed=getattr(self,'completedAt',0) |
completed=self.getCompletedAt() |
|
|
#completed leer |
#completed leer |
if completed=="" : |
if completed=="" : |
Line 613 class MPIWGProject(CatalogAware,Folder):
|
Line 658 class MPIWGProject(CatalogAware,Folder):
|
return True; |
return True; |
else: |
else: |
return False; |
return False; |
|
|
def getCompletedAt(self): |
def getCompletedAt(self): |
"""gibt das transformierte Datum zurueck, an dem das Projekt beendet wurde.""" |
"""gibt das transformierte Datum zurueck, an dem das Projekt beendet wurde.""" |
date=getattr(self,'completedAt','') |
date=getattr(self,'completedAt','') |
|
|
if date: |
if date: |
return self.reTransformDate(date); |
return self.reTransformDate(date); |
else: |
else: |
|
return "" |
# test ob parent abgeschlossen ist |
# test ob parent abgeschlossen ist |
|
try: #TODO: ersetzte try except durch vernuenftige abfrage |
ct=self.getContexts(parents=self.getContent('xdata_05'),depth=1) |
ct=self.getContexts(parents=self.getContent('xdata_05'),depth=1) |
if (len(ct)>0): #is there are parent |
if (len(ct)>0): #is there are parent |
|
|
return ct[0][0].getCompletedAt() |
return ct[0][0].getCompletedAt() |
return ''; |
return ''; |
|
except: |
|
return ''; |
|
|
def getStartedAt(self): |
def getStartedAt(self): |
"""gibt das transformierte Datum zurŸck, an dem Projekt begonnen wurde.""" |
"""gibt das transformierte Datum zurŸck, an dem Projekt begonnen wurde.""" |
Line 749 class MPIWGProject(CatalogAware,Folder):
|
Line 798 class MPIWGProject(CatalogAware,Folder):
|
|
|
def index_html(self,request=True,context=None): |
def index_html(self,request=True,context=None): |
"""show homepage""" |
"""show homepage""" |
|
|
|
bound_names={} |
|
|
|
if not context: |
|
context=self |
|
if request: |
|
if self.REQUEST.has_key('date') and self.REQUEST.SESSION.get('MPI_redirected',None)==None: |
|
self.REQUEST.SESSION['MPI_redirected']=1 |
|
self.REQUEST.RESPONSE.redirect(self.checkDate(self.REQUEST['date'])+"?date="+self.REQUEST['date']) |
|
else: |
|
self.REQUEST.SESSION['MPI_redirected']=None |
|
|
|
#ext=self.ZopeFind(self.aq_parent,obj_ids=["project_main"]) |
|
|
|
|
|
request2=getattr(self,'REQUEST',None) |
|
|
|
if request2 is not None: |
|
response = request2.response |
|
if not response.headers.has_key('content-type'): |
|
response.setHeader('content-type', 'text/html') |
|
|
|
security = getSecurityManager() |
|
bound_names['user'] = security.getUser() |
|
|
|
|
|
# Retrieve the value from the cache. |
|
keyset = None |
|
if self.ZCacheable_isCachingEnabled(): |
|
|
|
# Prepare a cache key. |
|
keyset = {'here': self, 'params':request2['QUERY_STRING']} |
|
|
|
result = self.ZCacheable_get(keywords=keyset) |
|
|
|
if result is not None: |
|
# Got a cached value. |
|
return result |
|
|
|
pt = getTemplate(self, "project_main") |
|
# Execute the template in a new security context. |
|
security.addContext(self) |
|
|
|
try: |
|
result = pt.pt_render(extra_context=bound_names) |
|
if keyset is not None: |
|
# Store the result in the cache. |
|
self.ZCacheable_set(result, keywords=keyset) |
|
|
|
return result |
|
finally: |
|
security.removeContext(self) |
|
|
|
|
|
|
|
def index_html_old(self,request=True,context=None): |
|
"""show homepage""" |
if not context: |
if not context: |
context=self |
context=self |
if request: |
if request: |
Line 759 class MPIWGProject(CatalogAware,Folder):
|
Line 865 class MPIWGProject(CatalogAware,Folder):
|
self.REQUEST.SESSION['MPI_redirected']=None |
self.REQUEST.SESSION['MPI_redirected']=None |
|
|
#ext=self.ZopeFind(self.aq_parent,obj_ids=["project_main"]) |
#ext=self.ZopeFind(self.aq_parent,obj_ids=["project_main"]) |
|
|
ext=getattr(self,"project_main",None) |
ext=getattr(self,"project_main",None) |
if ext: |
if ext: |
return getattr(self,ext.getId())() |
return getattr(self,ext.getId())() |
Line 788 class MPIWGProject(CatalogAware,Folder):
|
Line 895 class MPIWGProject(CatalogAware,Folder):
|
def getContent(self,field,filter=None): |
def getContent(self,field,filter=None): |
"""Inhalt des Feldes""" |
"""Inhalt des Feldes""" |
|
|
|
if field=="short_title": |
|
text = self.getContent("xdata_07") |
|
if text=="": |
|
text = self.getContent("WEB_title") |
|
return text |
|
|
text=u'' |
text=u'' |
|
|
for x in getattr(self,field): |
for x in getattr(self,field): |
Line 807 class MPIWGProject(CatalogAware,Folder):
|
Line 920 class MPIWGProject(CatalogAware,Folder):
|
except: |
except: |
pass |
pass |
|
|
if text=='': |
if text=='': ## wozu die folgenden Zeilen?? |
text2=text |
text2=text |
else: |
else: |
text2=re.sub(r';([^\s])','; \g<1>',text) |
text2=re.sub(r';([^\s])','; \g<1>',text) |
|
|
|
if field=="WEB_project_description":##Jedenfalls darf letzteres nicht gemacht werden, falls normaler text |
|
text2=text |
|
|
#teste ob ergebnis leer und header dann nehme title |
#teste ob ergebnis leer und header dann nehme title |
|
|
if (text2=='') and (field=='WEB_project_header'): |
if (text2=='') and (field=='WEB_project_header'): |
Line 900 class MPIWGProject(CatalogAware,Folder):
|
Line 1016 class MPIWGProject(CatalogAware,Folder):
|
return self.preview(newcontent) |
return self.preview(newcontent) |
|
|
self.copyObjectToArchive() |
self.copyObjectToArchive() |
|
self.ZCacheable_invalidate() |
self.WEB_project_description=newcontent[0:] |
self.WEB_project_description=newcontent[0:] |
|
|
self.REQUEST.RESPONSE.redirect("./index.html") |
self.REQUEST.RESPONSE.redirect("./index.html") |
Line 952 class MPIWGProject(CatalogAware,Folder):
|
Line 1069 class MPIWGProject(CatalogAware,Folder):
|
baseUrl = "/en/research/projects/" |
baseUrl = "/en/research/projects/" |
|
|
# add in the internal project hierarchy |
# add in the internal project hierarchy |
|
|
ct=self.getContexts(parents=self.getContent('xdata_05')) |
ct=self.getContexts(parents=self.getContent('xdata_05')) |
# start with grandparents |
# start with grandparents |
ct.reverse() |
ct.reverse() |
Line 966 class MPIWGProject(CatalogAware,Folder):
|
Line 1084 class MPIWGProject(CatalogAware,Folder):
|
|
|
def getRootProject(self): |
def getRootProject(self): |
"""returns the root (=top level) project of the current project""" |
"""returns the root (=top level) project of the current project""" |
|
|
ct=self.getContexts(parents=self.getContent('xdata_05')) |
ct=self.getContexts(parents=self.getContent('xdata_05')) |
if len(ct) > 0: |
if len(ct) > 0: |
return ct[-1][0] |
return ct[-1][0] |
Line 1109 class MPIWGProject(CatalogAware,Folder):
|
Line 1228 class MPIWGProject(CatalogAware,Folder):
|
lastname=self.myCapitalize(lastname).encode('utf-8') |
lastname=self.myCapitalize(lastname).encode('utf-8') |
logging.info("Search: %s %s %s"%(name,repr(firstname),repr(lastname))) |
logging.info("Search: %s %s %s"%(name,repr(firstname),repr(lastname))) |
try: |
try: |
cataloggedNames=self.MembersCatalog({'firstName':firstname,'lastName':lastname}) |
cataloggedNames=self.MembersCatalog(firstName=firstname,lastName=lastname) |
except: |
except: |
cataloggedNames=[] |
cataloggedNames=[] |
logging.error("ERROR: identifyNames %s %s"%sys.exc_info()[0:2]) |
logging.error("ERROR: identifyNames %s %s"%sys.exc_info()[0:2]) |
Line 1132 class MPIWGProject(CatalogAware,Folder):
|
Line 1251 class MPIWGProject(CatalogAware,Folder):
|
"""edit the project and archive the old version""" |
"""edit the project and archive the old version""" |
|
|
self.copyObjectToArchive() # archive the object |
self.copyObjectToArchive() # archive the object |
|
self.ZCacheable_invalidate() |
|
|
for x in definedFields: |
for x in definedFields: |
if self.REQUEST.has_key(x): |
if self.REQUEST.has_key(x): |
Line 1218 class MPIWGProject(CatalogAware,Folder):
|
Line 1337 class MPIWGProject(CatalogAware,Folder):
|
self.xdata_10="" |
self.xdata_10="" |
|
|
if fromEdit and (RESPONSE is not None): |
if fromEdit and (RESPONSE is not None): |
RESPONSE.redirect('./editMPIWGDisciplinesThemesEditor') |
self.redirect(RESPONSE,'./editMPIWGDisciplinesThemesEditor') |
|
|
else: |
else: |
if RESPONSE is not None: |
if RESPONSE is not None: |