--- MPIWGWeb/Attic/MPIWGTemplate.py 2008/08/28 18:20:09 1.1.2.3 +++ MPIWGWeb/Attic/MPIWGTemplate.py 2012/01/13 10:01:28 1.1.2.13 @@ -8,32 +8,20 @@ import logging from OFS.Folder import Folder from AccessControl import ClassSecurityInfo from MPIWGHelper import * +from ZODB import FileStorage, DB +import transaction +# dummy definitions for backwards compatibility +import MPIWGFeature -def getBreadcrumbs(self): - """return list of breadcrumbs from here to the root""" - crumbs = [(self.title, self.absolute_url(), self)] - parent = self.aq_parent - if hasattr(parent, 'getBreadcrumbs'): - if self.title: - return parent.getBreadcrumbs() + crumbs - else: - # if there's no title, skip this level - return parent.getBreadcrumbs() - - return crumbs +class MPIWGFeature(MPIWGFeature.MPIWGFeature): + """deprecated! use class in MPIWGFeature.py""" +import MPIWGFolder + +class MPIWGFolder(MPIWGFolder.MPIWGFolder): + """deprecated! use class in MPIWGFolder.py""" -def getSection(self): - """returns the current section name""" - p = self - sec = None - # descend parents to the root (and remember the last id) - while p is not None and p.meta_type != 'MPIWGRoot': - sec = p.getId() - p = p.aq_parent - - return sec class MPIWGTemplate(ZopePageTemplate): @@ -75,10 +63,34 @@ class MPIWGTemplate(ZopePageTemplate): return "" getBreadcrumbs = getBreadcrumbs - getSection = getSection + getSubSection = getSubSection + + def harvest_page(self,mode="normal"): + """harvest main""" + + + # Ensure that a 'userdb' key is present + # in the root + + templates = self.en.getHarvestCache() + #templates = getattr(self,'getHarvestCache',self.en.getHarvestCache)() + try: + + rendered = self.pt_render() + templates[self.absolute_url()]=rendered + logging.debug("harvest:"+self.absolute_url()) + transaction.commit() + return rendered + except: + logging.error("cannot harvest: %s"%self.absolute_url()) + + + + + def manage_addMPIWGTemplateForm(self): """Form for adding""" pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt/AddMPIWGTemplate.zpt')).__of__(self) @@ -126,67 +138,4 @@ def manage_addMPIWGTemplate(self, MPIWGT REQUEST.RESPONSE.redirect(u+'/manage_main') return '' - - - -class MPIWGFolder(Folder): - """special Folder object for MPIWG website """ - - meta_type="MPIWGFolder" - - manage_options=Folder.manage_options+( - {'label':'Change Weight','action':'changeWeightForm'}, - {'label':'Main Config','action':'changeForm'}, - ) - - changeWeightForm = PageTemplateFile('zpt/MPIWGFolderChangeWeight', globals()) - changeForm = PageTemplateFile('zpt/MPIWGFolderConfig', globals()) - - def __init__(self, id, title=None, weight=0, canonicalName=None): - self.id = str(id) - self.weight = weight - if title is None: - self.title = id - else: - self.title = title - - if canonicalName is None: - self.canonicalName = self.id - else: - self.canonicalName = canonicalName - - def changeWeight(self,weight,RESPONSE=None): - """change weight""" - self.weight=weight - if RESPONSE is not None: - RESPONSE.redirect('manage_main') - - def changeMPIWGFolder(self, title=None, weight=None, canonicalName=None, RESPONSE=None): - """change everything""" - if title is not None: - self.title = title - if weight is not None: - self.weight = weight - if canonicalName is not None: - self.canonicalName = canonicalName - if RESPONSE is not None: - RESPONSE.redirect('manage_main') - - getBreadcrumbs = getBreadcrumbs - - getSection = getSection - -def manage_addMPIWGFolderForm(self): - """Form for adding""" - pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt/AddMPIWGFolder.zpt')).__of__(self) - return pt() - -def manage_addMPIWGFolder(self, id, title=None,weight=0,RESPONSE=None): - "Add a MPIWG Folder." - newObj=MPIWGFolder(id,title,weight) - self.Destination()._setObject(id,newObj) - if RESPONSE is not None: - RESPONSE.redirect('manage_main') - - \ No newline at end of file