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
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
......
......@@ -27,6 +27,8 @@ from Products.Five.browser.pagetemplatefile import ZopeTwoPageTemplateFile
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 @@ class ViewletManagerBase(origManagerBase):
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 @@ def ViewletManager(name, interface, template=None, bases=()):
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
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