[Checkins]
SVN: five.customerize/branches/baarn-sprint/src/five/customerize/
introduced an interface for a container holding all
customized templates, so they don't clutter up the site
folder (which in case of plone will be the site root, which
is pretty crowded already anyway);
if no utility implementing the container interface can be found, the
old behaviour (adding to the nearest site) is used as a fallback
Andreas Zeidler
az at zitc.de
Mon Feb 19 12:47:35 EST 2007
Log message for revision 72687:
introduced an interface for a container holding all customized templates, so they don't clutter up the site folder (which in case of plone will be the site root, which is pretty crowded already anyway); if no utility implementing the container interface can be found, the old behaviour (adding to the nearest site) is used as a fallback
Changed:
U five.customerize/branches/baarn-sprint/src/five/customerize/browser.py
U five.customerize/branches/baarn-sprint/src/five/customerize/interfaces.py
-=-
Modified: five.customerize/branches/baarn-sprint/src/five/customerize/browser.py
===================================================================
--- five.customerize/branches/baarn-sprint/src/five/customerize/browser.py 2007-02-19 17:46:48 UTC (rev 72686)
+++ five.customerize/branches/baarn-sprint/src/five/customerize/browser.py 2007-02-19 17:47:35 UTC (rev 72687)
@@ -15,7 +15,9 @@
from zope.app.apidoc.presentation import getViews
from five.customerize.zpt import TTWViewTemplate
+from five.customerize.interfaces import IViewTemplateContainer
+
def mangleAbsoluteFilename(filename):
"""
Mangle an absolute filename when the file happens to be in a
@@ -120,7 +122,7 @@
# find the nearest site
site = findSite(self.context, IObjectManagerSite)
if site is None:
- raise TypeError("No site found") #TODO find right exception
+ raise TypeError("No site found") # TODO find right exception
# we're using the original filename of the template, not the
# view name to avoid potential conflicts and/or confusion in
@@ -133,8 +135,12 @@
permission = self.permissionFromViewName(viewname)
viewzpt = TTWViewTemplate(zpt_id, template_file, view=viewclass,
permission=permission)
- site._setObject(zpt_id, viewzpt) #XXXthere could be a naming conflict
- components = site.getSiteManager()
+ container = zope.component.queryUtility(IViewTemplateContainer)
+ if container is not None:
+ viewzpt = container.addTemplate(zpt_id, viewzpt)
+ else:
+ site._setObject(zpt_id, viewzpt) #XXXthere could be a naming conflict
+ viewzpt = getattr(site, zpt_id)
# find out the view registration object so we can get at the
# provided and required interfaces
@@ -143,11 +149,11 @@
if reg.name == viewname:
break
+ components = site.getSiteManager()
components.registerAdapter(viewzpt, required=reg.required,
provided=reg.provided, name=viewname
) #XXX info?
- viewzpt = getattr(site, zpt_id)
return viewzpt
def customizeTemplate(self, viewname):
Modified: five.customerize/branches/baarn-sprint/src/five/customerize/interfaces.py
===================================================================
--- five.customerize/branches/baarn-sprint/src/five/customerize/interfaces.py 2007-02-19 17:46:48 UTC (rev 72686)
+++ five.customerize/branches/baarn-sprint/src/five/customerize/interfaces.py 2007-02-19 17:47:35 UTC (rev 72687)
@@ -7,3 +7,11 @@
def __call__(context, request):
""" render the template/view """
+
+class IViewTemplateContainer(Interface):
+ """ container for all ttw view template objects """
+
+ def addTemplate(id, template):
+ """ add the given ttw view template to the container
+ and return it acquisition wrapped in the container """
+
More information about the Checkins
mailing list