Commit 9d22d6e2 authored by Malthe Borch's avatar Malthe Borch

Forward-ported viewlet manager directive fix (see c69896).

parent 197985ce
...@@ -219,6 +219,10 @@ Zope Changes ...@@ -219,6 +219,10 @@ Zope Changes
Bugs Fixed 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. - Made Five.testbrowser compatible with mechanize 0.1.7b.
- Ensure that response header values cannot embed CRLF pairs, which - Ensure that response header values cannot embed CRLF pairs, which
......
...@@ -27,6 +27,8 @@ from Products.Five.browser.pagetemplatefile import ZopeTwoPageTemplateFile ...@@ -27,6 +27,8 @@ from Products.Five.browser.pagetemplatefile import ZopeTwoPageTemplateFile
class ViewletManagerBase(origManagerBase): class ViewletManagerBase(origManagerBase):
"""A base class for Viewlet managers to work in Zope2""" """A base class for Viewlet managers to work in Zope2"""
template = None
def __getitem__(self, name): def __getitem__(self, name):
"""See zope.interface.common.mapping.IReadMapping""" """See zope.interface.common.mapping.IReadMapping"""
# Find the viewlet # Find the viewlet
...@@ -75,9 +77,10 @@ class ViewletManagerBase(origManagerBase): ...@@ -75,9 +77,10 @@ class ViewletManagerBase(origManagerBase):
return sorted(viewlets, lambda x, y: cmp(aq_base(x[1]), aq_base(y[1]))) return sorted(viewlets, lambda x, y: cmp(aq_base(x[1]), aq_base(y[1])))
def ViewletManager(name, interface, template=None, bases=()): def ViewletManager(name, interface, template=None, bases=()):
attrDict = {'__name__': name}
if template is not None: if template is not None:
template = ZopeTwoPageTemplateFile(template) attrDict['template'] = ZopeTwoPageTemplateFile(template)
if ViewletManagerBase not in bases: if ViewletManagerBase not in bases:
# Make sure that we do not get a default viewlet manager mixin, if the # Make sure that we do not get a default viewlet manager mixin, if the
...@@ -87,8 +90,7 @@ def ViewletManager(name, interface, template=None, bases=()): ...@@ -87,8 +90,7 @@ def ViewletManager(name, interface, template=None, bases=()):
bases = bases + (ViewletManagerBase,) bases = bases + (ViewletManagerBase,)
ViewletManager = type( ViewletManager = type(
'<ViewletManager providing %s>' % interface.getName(), '<ViewletManager providing %s>' % interface.getName(), bases, attrDict)
bases,
{'template': template, '__name__': name})
zope.interface.classImplements(ViewletManager, interface) zope.interface.classImplements(ViewletManager, interface)
return ViewletManager return ViewletManager
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment