--- MPIWGWeb/MPIWGStaff.py 2008/09/12 15:54:49 1.10.2.61 +++ MPIWGWeb/MPIWGStaff.py 2008/10/22 11:27:42 1.10.2.62 @@ -7,8 +7,10 @@ from OFS.Folder import Folder from Products.ZSQLExtend.ZSQLExtend import ZSQLExtendFolder from Products.PageTemplates.PageTemplateFile import PageTemplateFile from Products.PageTemplates.PageTemplate import PageTemplate +from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate from Products.ZCatalog.CatalogPathAwareness import CatalogAware from Products.versionedFile.extVersionedFile import extVersionedFileFolder +from AccessControl import getSecurityManager import os import logging @@ -134,7 +136,7 @@ class MPIWGStaff(CatalogAware,ZSQLExtend return False - + def updateDBEntry(self,publish_the_data,date_from,date_to,DBid=None,stay_at_mpiwg="",position="",abteilung=""): """zpddatedb""" if not DBid: @@ -163,7 +165,7 @@ class MPIWGStaff(CatalogAware,ZSQLExtend """change PublicationSelectionMode""" self.publicationSelectionMode=publicationSelectionMode - + self.ZCacheable_invalidate() if RESPONSE: self.redirect(RESPONSE,"editPublications") @@ -196,7 +198,7 @@ class MPIWGStaff(CatalogAware,ZSQLExtend def changeDownloads(self,cv_pdf=None,cv_publish=None,publications_pdf=None,publications_publish=None,RESPONSE=None): """"change the downloadable files""" - + self.ZCacheable_invalidate() if not hasattr(self,'downloadableFiles'): extFolder = extVersionedFileFolder() @@ -299,8 +301,9 @@ class MPIWGStaff(CatalogAware,ZSQLExtend manage_options = Folder.manage_options+( {'label':'Edit','action':'changeMPIWGStaffForm'}, {'label':'Change Publications Special','action':'changePublications_specialForm'}, - ) + ) + Cacheable.manage_options + __manager_id = "ramCache" def __init__(self,id, lastName,firstName,key): """init""" self.id=id @@ -343,9 +346,46 @@ class MPIWGStaff(CatalogAware,ZSQLExtend def index_html(self): """show homepage""" + + bound_names={} + request = self.REQUEST + if request is not None: + response = request.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} + + result = self.ZCacheable_get(keywords=keyset) + + if result is not None: + # Got a cached value. + return result + pt = getTemplate(self, "members_main") - return pt() + # 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 changePublications_specialForm(self): """Priority publications manual field""" pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','changePublications_special.zpt')).__of__(self) @@ -353,6 +393,7 @@ class MPIWGStaff(CatalogAware,ZSQLExtend def changePublications_special(self,usePublicationsSpecial=None,specialPublicationsField=None,RESPONSE=None): """change publications special params""" + self.ZCacheable_invalidate() if usePublicationsSpecial: self.usePublicationsSpecial=True @@ -388,6 +429,7 @@ class MPIWGStaff(CatalogAware,ZSQLExtend security.declareProtected('View management screens','changeMPIWGStaff') def changeMPIWGStaff(self,lastName,firstName,key=None,RESPONSE=None): """change it""" + self.ZCacheable_invalidate() self.title="%s, %s"%(lastName,firstName) self.lastName=lastName self.firstName=firstName @@ -461,13 +503,14 @@ class MPIWGStaff(CatalogAware,ZSQLExtend query="UPDATE personal_www SET current_work_p =%s WHERE key='%s'" self.ZSQLQuery(query%(self.ZSQLQuote(publish),key)) - + self.ZCacheable_invalidate() if RESPONSE: self.redirect(RESPONSE,"edit") security.declareProtected('View management screens','changeResearch') def changeResearch(self,noredirect=None,RESPONSE=None): """change the research entries""" + self.ZCacheable_invalidate() newEntries={} key_main=self.REQUEST.form['key_main'] @@ -526,7 +569,7 @@ class MPIWGStaff(CatalogAware,ZSQLExtend return pt() query="UPDATE personal_www SET cv =%s WHERE oid='%s'" - + self.ZCacheable_invalidate() self.ZSQLQuery(query%(self.ZSQLQuote(cv),oid)) if RESPONSE: @@ -548,12 +591,12 @@ class MPIWGStaff(CatalogAware,ZSQLExtend def editProfile(self,oid=None,RESPONSE=None, kupu=None, preview=None): """edit Profile, new entry replaces CD, current work and research interests""" - + if (not oid): pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editProfile.zpt')).__of__(self) return pt() - + self.ZCacheable_invalidate() if preview: @@ -627,7 +670,7 @@ class MPIWGStaff(CatalogAware,ZSQLExtend if (not oid): pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editAwards.zpt')).__of__(self) return pt() - + self.ZCacheable_invalidate() query="UPDATE personal_www SET awards =%s WHERE oid='%s'" self.ZSQLQuery(query%(self.ZSQLQuote(awards),oid)) @@ -658,7 +701,7 @@ class MPIWGStaff(CatalogAware,ZSQLExtend security.declareProtected('View management screens','editMainData') def editMainData(self,REQUEST=None,RESPONSE=None): """edit main data""" - + self.ZCacheable_invalidate() argv=REQUEST.form if not argv.has_key('last_name'): @@ -723,6 +766,7 @@ class MPIWGStaff(CatalogAware,ZSQLExtend def changeSortingMode(self,sortingMode,RESPONSE=None,REQUEST=None): """change sorting mode""" + self.ZCacheable_invalidate() self.sortingMode=sortingMode if RESPONSE and REQUEST: @@ -748,7 +792,7 @@ class MPIWGStaff(CatalogAware,ZSQLExtend def changePublications(self,RESPONSE=None): """change the publication list""" self.changeResearch(noredirect=True) - + self.ZCacheable_invalidate() #self.updatePublicationDB(personId=self.getDBId()) self.redirect(RESPONSE,self.REQUEST['HTTP_REFERER'])