[Zope-Checkins] SVN: Zope/trunk/ Forward-ported viewlet manager directive fix (see c69896).

Malthe Borch mborch at gmail.com
Sat Nov 15 13:02:17 EST 2008


Log message for revision 92984:
  Forward-ported viewlet manager directive fix (see c69896).

Changed:
  U   Zope/trunk/doc/CHANGES.txt
  U   Zope/trunk/lib/python/Products/Five/viewlet/manager.py

-=-
Modified: Zope/trunk/doc/CHANGES.txt
===================================================================
--- Zope/trunk/doc/CHANGES.txt	2008-11-15 18:00:32 UTC (rev 92983)
+++ Zope/trunk/doc/CHANGES.txt	2008-11-15 18:02:16 UTC (rev 92984)
@@ -219,6 +219,10 @@
 
     Bugs Fixed
 
+      - Ported c69896 to Five. This fix makes it possible to provide a
+        template using Python, and not have it being set to `None` by
+        the viewlet manager directive.
+    
       - Made Five.testbrowser compatible with mechanize 0.1.7b.
 
       - Ensure that response header values cannot embed CRLF pairs, which

Modified: Zope/trunk/lib/python/Products/Five/viewlet/manager.py
===================================================================
--- Zope/trunk/lib/python/Products/Five/viewlet/manager.py	2008-11-15 18:00:32 UTC (rev 92983)
+++ Zope/trunk/lib/python/Products/Five/viewlet/manager.py	2008-11-15 18:02:16 UTC (rev 92984)
@@ -27,6 +27,8 @@
 class ViewletManagerBase(origManagerBase):
     """A base class for Viewlet managers to work in Zope2"""
 
+    template = None
+    
     def __getitem__(self, name):
         """See zope.interface.common.mapping.IReadMapping"""
         # Find the viewlet
@@ -75,9 +77,10 @@
         return sorted(viewlets, lambda x, y: cmp(aq_base(x[1]), aq_base(y[1])))
 
 def ViewletManager(name, interface, template=None, bases=()):
-
+    attrDict = {'__name__': name}
+    
     if template is not None:
-        template = ZopeTwoPageTemplateFile(template)
+        attrDict['template'] = ZopeTwoPageTemplateFile(template)
 
     if ViewletManagerBase not in bases:
         # Make sure that we do not get a default viewlet manager mixin, if the
@@ -87,8 +90,7 @@
             bases = bases + (ViewletManagerBase,)
 
     ViewletManager = type(
-        '<ViewletManager providing %s>' % interface.getName(),
-        bases,
-        {'template': template, '__name__': name})
+        '<ViewletManager providing %s>' % interface.getName(), bases, attrDict)
+
     zope.interface.classImplements(ViewletManager, interface)
     return ViewletManager



More information about the Zope-Checkins mailing list