[Checkins] SVN: z3c.pagelet/trunk/ - Fix ``IPageletDirective`` after a change in ``zope.component.zcml.IBasicViewInformation``
Adam Groszer
cvs-admin at zope.org
Sat Sep 15 13:01:55 UTC 2012
Log message for revision 127844:
- Fix ``IPageletDirective`` after a change in ``zope.component.zcml.IBasicViewInformation``
Changed:
U z3c.pagelet/trunk/CHANGES.txt
U z3c.pagelet/trunk/src/z3c/pagelet/zcml.py
U z3c.pagelet/trunk/src/z3c/pagelet/zcml.txt
-=-
Modified: z3c.pagelet/trunk/CHANGES.txt
===================================================================
--- z3c.pagelet/trunk/CHANGES.txt 2012-09-14 15:57:07 UTC (rev 127843)
+++ z3c.pagelet/trunk/CHANGES.txt 2012-09-15 13:01:48 UTC (rev 127844)
@@ -5,7 +5,8 @@
1.3.1 (unreleased)
------------------
-- ...
+- Fix ``IPageletDirective`` after a change in
+ ``zope.component.zcml.IBasicViewInformation``
1.3.0 (2011-10-29)
@@ -17,7 +18,7 @@
- Upgrade to chameleon 2.0 template engine and use the newest z3c.pt and
z3c.ptcompat packages adjusted to work with chameleon 2.0.
-
+
See the notes from the z3c.ptcompat package:
Update z3c.ptcompat implementation to use component-based template engine
@@ -29,14 +30,14 @@
Note that the ``PREFER_Z3C_PT`` environment option has been
rendered obsolete; instead, this is now managed via component
configuration.
-
+
Also note that the chameleon CHAMELEON_CACHE environment value changed from
True/False to a path. Skip this property if you don't like to use a cache.
None or False defined in buildout environment section doesn't work. At least
with chameleon <= 2.5.4
-
+
Attention: You need to include the configure.zcml file from z3c.ptcompat
- for enable the z3c.pt template engine. The configure.zcml will plugin the
+ for enable the z3c.pt template engine. The configure.zcml will plugin the
template engine. Also remove any custom built hooks which will import
z3c.ptcompat in your tests or other places.
Modified: z3c.pagelet/trunk/src/z3c/pagelet/zcml.py
===================================================================
--- z3c.pagelet/trunk/src/z3c/pagelet/zcml.py 2012-09-14 15:57:07 UTC (rev 127843)
+++ z3c.pagelet/trunk/src/z3c/pagelet/zcml.py 2012-09-15 13:01:48 UTC (rev 127844)
@@ -56,6 +56,13 @@
required=True
)
+ layer = zope.configuration.fields.GlobalObject(
+ title=u"The request interface or class this pagelet is for.",
+ description=
+ u"Defaults to zope.publisher.interfaces.browser.IDefaultBrowserLayer.",
+ required=False
+ )
+
for_ = zope.configuration.fields.GlobalObject(
title=u"Context",
description=u"The content interface or class this pagelet is for.",
Modified: z3c.pagelet/trunk/src/z3c/pagelet/zcml.txt
===================================================================
--- z3c.pagelet/trunk/src/z3c/pagelet/zcml.txt 2012-09-14 15:57:07 UTC (rev 127843)
+++ z3c.pagelet/trunk/src/z3c/pagelet/zcml.txt 2012-09-15 13:01:48 UTC (rev 127844)
@@ -2,7 +2,7 @@
Pagelet directive
=================
-Show how we can use the pagelet directive. Register the meta configuration for
+Show how we can use the pagelet directive. Register the meta configuration for
the directive.
>>> import sys
@@ -19,7 +19,7 @@
Make them available under the fake package ``custom``:
>>> sys.modules['custom'] = type(
- ... 'Module', (),
+ ... 'Module', (),
... {'MyPagelet': MyPagelet})()
Register a pagelet within the directive with minimal attributes:
@@ -39,7 +39,7 @@
>>> import zope.component
>>> from zope.publisher.browser import TestRequest
- >>> pagelet = zope.component.queryMultiAdapter((object(), TestRequest()),
+ >>> pagelet = zope.component.queryMultiAdapter((object(), TestRequest()),
... name='index.html')
and check them:
@@ -51,7 +51,7 @@
<object object at ...>
Register the pagelet with a different name and more attributes provided from
-the directive. We also use a custom attribute called label here. Let's define
+the directive. We also use a custom attribute called label here. Let's define
some more components...
>>> class SecondPagelet(BrowserPagelet):
@@ -87,7 +87,7 @@
Get the pagelet for the new content object
>>> import zope.component
- >>> pagelet = zope.component.queryMultiAdapter((Content(), TestRequest()),
+ >>> pagelet = zope.component.queryMultiAdapter((Content(), TestRequest()),
... name='custom.html')
and check them:
@@ -104,7 +104,7 @@
>>> class NewPagelet(BrowserPagelet):
... """New pagelet"""
>>> sys.modules['custom'] = type(
- ... 'Module', (),
+ ... 'Module', (),
... {'NewPagelet': NewPagelet})()
Now register the pagelet within a interface which isn't inherited from IPagelet.
@@ -131,7 +131,7 @@
>>> class INewPagelet(interfaces.IPagelet):
... """New pagelet interface."""
>>> sys.modules['custom'] = type(
- ... 'Module', (),
+ ... 'Module', (),
... {'INewPagelet': INewPagelet, 'NewPagelet': NewPagelet})()
>>> context = xmlconfig.string("""
@@ -146,10 +146,10 @@
... </configure>
... """, context)
-And if we get the pagelet, we can see that the object provides the new
+And if we get the pagelet, we can see that the object provides the new
pagelet interface:
- >>> pagelet = zope.component.queryMultiAdapter((object(), TestRequest()),
+ >>> pagelet = zope.component.queryMultiAdapter((object(), TestRequest()),
... name='new.html')
>>> pagelet
<z3c.pagelet.zcml.NewPagelet object at ...>
@@ -157,6 +157,54 @@
>>> INewPagelet.providedBy(pagelet)
True
+Register a pagelet for a layer:
+
+ >>> class SkinnedPagelet(BrowserPagelet):
+ ... """Custom pagelet"""
+
+ >>> from zope.publisher.interfaces.browser import IDefaultBrowserLayer
+ >>> class IMyPageletLayer(IDefaultBrowserLayer):
+ ... """Custom layer"""
+
+ >>> sys.modules['custom'] = type(
+ ... 'Module', (),
+ ... {'SkinnedPagelet': SkinnedPagelet,
+ ... 'IMyPageletLayer': IMyPageletLayer})()
+
+ >>> context = xmlconfig.string("""
+ ... <configure
+ ... xmlns:z3c="http://namespaces.zope.org/z3c">
+ ... <z3c:pagelet
+ ... name="skinned.html"
+ ... layer="custom.IMyPageletLayer"
+ ... class="custom.SkinnedPagelet"
+ ... permission="zope.Public"
+ ... />
+ ... </configure>
+ ... """, context)
+
+
+ >>> from zope.publisher.skinnable import applySkin
+ >>> req = TestRequest()
+ >>> applySkin(req, IMyPageletLayer)
+ >>> pagelet = zope.component.queryMultiAdapter((object(), req),
+ ... name='skinned.html')
+
+and check them:
+
+ >>> pagelet
+ <z3c.pagelet.zcml.SkinnedPagelet object at ...>
+
+ >>> pagelet.context
+ <object object at ...>
+
+
+
+Cleanup
+--------
+
Now we need to clean up the custom module.
>>> del sys.modules['custom']
+
+
More information about the checkins
mailing list