[Checkins] SVN: z3ext.layout/trunk/ 'name' attribute is optional for <z3ext:pagelet/> directive
Nikolay Kim
fafhrd at datacom.kz
Mon Aug 18 03:52:15 EDT 2008
Log message for revision 89954:
'name' attribute is optional for <z3ext:pagelet/> directive
Changed:
U z3ext.layout/trunk/CHANGES.txt
U z3ext.layout/trunk/src/z3ext/layout/pagelet.txt
U z3ext.layout/trunk/src/z3ext/layout/zcml.py
-=-
Modified: z3ext.layout/trunk/CHANGES.txt
===================================================================
--- z3ext.layout/trunk/CHANGES.txt 2008-08-18 07:34:48 UTC (rev 89953)
+++ z3ext.layout/trunk/CHANGES.txt 2008-08-18 07:52:14 UTC (rev 89954)
@@ -2,6 +2,12 @@
CHANGES
=======
+1.4.5 (2008-08-18)
+------------------
+
+- `name` attribute is optional for <z3ext:pagelet/> directive
+
+
1.4.4 (2008-07-22)
------------------
Modified: z3ext.layout/trunk/src/z3ext/layout/pagelet.txt
===================================================================
--- z3ext.layout/trunk/src/z3ext/layout/pagelet.txt 2008-08-18 07:34:48 UTC (rev 89953)
+++ z3ext.layout/trunk/src/z3ext/layout/pagelet.txt 2008-08-18 07:52:14 UTC (rev 89954)
@@ -220,4 +220,23 @@
<z3ext.layout.zcml.PageletClass from <class 'z3ext.layout.TESTS.MyPagelet'> ...>
>>> view.__name__
- u'index.html'
\ No newline at end of file
+ u'index.html'
+
+
+Pagelet without name
+
+ >>> class IMyPagelet(interface.Interface):
+ ... pass
+
+ >>> context = xmlconfig.string("""
+ ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext">
+ ... <z3ext:pagelet
+ ... template="%s"
+ ... provides="z3ext.layout.TESTS.IMyPagelet"
+ ... permission="zope.Public" />
+ ... </configure>
+ ... """%template, context)
+
+ >>> pagelet = component.queryMultiAdapter((object(), TestRequest()), IMyPagelet)
+ >>> IMyPagelet.providedBy(pagelet)
+ True
\ No newline at end of file
Modified: z3ext.layout/trunk/src/z3ext/layout/zcml.py
===================================================================
--- z3ext.layout/trunk/src/z3ext/layout/zcml.py 2008-08-18 07:34:48 UTC (rev 89953)
+++ z3ext.layout/trunk/src/z3ext/layout/zcml.py 2008-08-18 07:52:14 UTC (rev 89954)
@@ -48,7 +48,7 @@
name = schema.TextLine(
title = u"The name of the pagelet.",
description = u"The name shows up in URLs/paths. For example 'foo'.",
- required = True)
+ required = False)
provides = Tokens(
title = u"The interface this pagelets provides.",
@@ -265,7 +265,7 @@
# pagelet directive
def pageletDirective(
- _context, name, permission, class_=None, for_=interface.Interface,
+ _context, permission, name=u'', class_=None, for_=interface.Interface,
layer=IDefaultBrowserLayer, provides=[IPagelet,],
allowed_interface=[], allowed_attributes=[],
template=u'', layout=u'', **kwargs):
@@ -284,11 +284,6 @@
raise ConfigurationError("No such file", template)
kwargs['template'] = ViewPageTemplateFile(template)
- # check interfaces
- ifaces = list(interface.Declaration(provides).flattened())
- if IPagelet not in ifaces:
- provides.append(IPagelet)
-
# Build a new class that we can use different permission settings if we
# use the class more then once.
cdict = {}
@@ -308,6 +303,9 @@
# prepare allowed interfaces and attributes
allowed_interface.extend(provides)
+ if IPagelet not in provides:
+ allowed_interface.append(IPagelet)
+
allowed_attributes.extend(kwargs.keys())
allowed_attributes.extend(('__call__', 'browserDefault',
'update', 'render', 'publishTraverse'))
@@ -330,11 +328,12 @@
defineChecker(new_class, Checker(required))
# register pagelet
- _context.action(
- discriminator = ('z3ext:pagelet', for_, layer, name),
- callable = handler,
- args = ('registerAdapter',
- new_class, (for_, layer), IPagelet, name, _context.info))
+ for iface in provides:
+ _context.action(
+ discriminator = ('z3ext:pagelet', for_, layer, name),
+ callable = handler,
+ args = ('registerAdapter',
+ new_class, (for_, layer), iface, name, _context.info))
def _handle_allowed_interface(
More information about the Checkins
mailing list