--- MPIWGWeb/MPIWGProjects.py 2008/10/23 10:02:09 1.47.2.108 +++ MPIWGWeb/MPIWGProjects.py 2009/02/18 15:42:00 1.47.2.109 @@ -13,6 +13,7 @@ from Globals import package_home import urllib import re import os +import email from types import * import logging import xmlhelper # Methoden zur Verwaltung der projekt xml @@ -57,6 +58,19 @@ class MPIWGProject_publication(Folder): """publications object fuer project""" 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): """edit a publication""" @@ -83,10 +97,10 @@ class MPIWGProject_publication(Folder): nO = Image('publicationImage2','',image2) self._setObject('publicationImage2',nO) - + if RESPONSE: - RESPONSE.redirect("../managePublications") - + self.redirect(RESPONSE,"../managePublications") + class MPIWGProject_image(Image): """Images for Projects""" @@ -111,7 +125,8 @@ class MPIWGProject_image(Image): self.caption=caption[0:] if RESPONSE: - RESPONSE.redirect("../manageImages") + + self.redirect(RESPONSE,"../manageImages") class MPIWGProject(CatalogAware,Folder,Cacheable): """Class for Projects""" @@ -120,6 +135,19 @@ class MPIWGProject(CatalogAware,Folder,C security=ClassSecurityInfo() meta_type='MPIWGProject' 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): """return unicode object""" @@ -149,7 +177,8 @@ class MPIWGProject(CatalogAware,Folder,C self.addPublication(pubSplit) if RESPONSE: - RESPONSE.redirect('managePublications') + + self.redirect(RESPONSE,'managePublications') def copyImageToMargin(self,RESPONSE=None): @@ -218,7 +247,8 @@ class MPIWGProject(CatalogAware,Folder,C obj.update_data(data) if RESPONSE: - RESPONSE.redirect('manageImages') + + self.redirect(RESPONSE,'manageImages') def manageImages(self,imageName=None,op=None): """managage images""" @@ -297,7 +327,8 @@ class MPIWGProject(CatalogAware,Folder,C if RESPONSE: - RESPONSE.redirect("managePublications") + self.redirect(RESPONSE,"managePublications") + def getPublications(self): """get all Publications""" @@ -324,7 +355,8 @@ class MPIWGProject(CatalogAware,Folder,C obj.id=name if RESPONSE is not None: - RESPONSE.redirect('managePublications') + + self.redirect(RESPONSE,'managePublications') def getLastPublicationNumber(self): @@ -339,7 +371,8 @@ class MPIWGProject(CatalogAware,Folder,C """delete Publication id""" self.manage_delObjects([id]) if RESPONSE: - RESPONSE.redirect('managePublications') + + self.redirect(RESPONSE,'managePublications') def getImages(self): """get all Images""" @@ -376,7 +409,8 @@ class MPIWGProject(CatalogAware,Folder,C except: logging.error("ERROR MPIWG: %s %s"%sys.exc_info()[0:2]) if RESPONSE: - RESPONSE.redirect('manageImages') + self.redirect(RESPONSE,'manageImages') + def hasChildren(self,date=None,onlyActive=1,onlyArchived=1): @@ -410,7 +444,8 @@ class MPIWGProject(CatalogAware,Folder,C obj.id=filename if RESPONSE is not None: - RESPONSE.redirect('manageImages') + + self.redirect(RESPONSE,'manageImages') def PrincipiaSearchSource(self): """Return cataloguable key for ourselves.""" @@ -505,7 +540,8 @@ class MPIWGProject(CatalogAware,Folder,C self.invisible=invisible if RESPONSE is not None: - RESPONSE.redirect('manage_main') + + self.redirect(RESPONSE,'manage_main') def crossLinker(self): @@ -541,7 +577,7 @@ class MPIWGProject(CatalogAware,Folder,C self._setObject(id,newObj) #self.manage_addPageTemplate(id,title) if RESPONSE is not None: - RESPONSE.redirect('manage_main') + self.redirect(RESPONSE,'manage_main') def __init__(self, id, argv=None): """initiere classe""" @@ -1295,7 +1331,7 @@ class MPIWGProject(CatalogAware,Folder,C self.xdata_10="" if fromEdit and (RESPONSE is not None): - RESPONSE.redirect('./editMPIWGDisciplinesThemesEditor') + self.redirect(RESPONSE,'./editMPIWGDisciplinesThemesEditor') else: if RESPONSE is not None: