[Checkins] SVN: z3c.pagelet/tags/1.2.0/ Tag 1.2.0

Dan Korostelev nadako at gmail.com
Thu Aug 27 12:34:19 EDT 2009


Log message for revision 103307:
  Tag 1.2.0

Changed:
  A   z3c.pagelet/tags/1.2.0/
  D   z3c.pagelet/tags/1.2.0/CHANGES.txt
  A   z3c.pagelet/tags/1.2.0/CHANGES.txt
  D   z3c.pagelet/tags/1.2.0/setup.py
  A   z3c.pagelet/tags/1.2.0/setup.py
  D   z3c.pagelet/tags/1.2.0/src/z3c/pagelet/README.txt
  A   z3c.pagelet/tags/1.2.0/src/z3c/pagelet/README.txt
  D   z3c.pagelet/tags/1.2.0/src/z3c/pagelet/zcml.py
  A   z3c.pagelet/tags/1.2.0/src/z3c/pagelet/zcml.py

-=-
Deleted: z3c.pagelet/tags/1.2.0/CHANGES.txt
===================================================================
--- z3c.pagelet/trunk/CHANGES.txt	2009-08-27 15:20:32 UTC (rev 103295)
+++ z3c.pagelet/tags/1.2.0/CHANGES.txt	2009-08-27 16:34:19 UTC (rev 103307)
@@ -1,52 +0,0 @@
-=======
-CHANGES
-=======
-
-1.1.1 (unreleased)
-------------------
-
-- Nothing changed yet.
-
-
-1.1.0 (2009-05-28)
-------------------
-
-* Got rid of dependency on ``zope.app.component`` by requiring
-  ``zope.component >= 3.7``.
-
-* Removed hard dependency on ``zope.formlib``: the pagelet forms now
-  only get defined when ``zope.formlib`` is available. Tests still
-  depend on ``zope.formlib``, so it got a test dependency.
-
-* Made sure long_description renders fine on pypi.
-
-
-1.0.3 (2009-02-27)
-------------------
-
-* Allow use of ``z3c.pt`` using ``z3c.ptcompat`` compatibility layer.
-
-* Add support for context-specific layout and content template lookup,
-  using (view, request, context) discriminator. This is compatible with
-  context-specific templates introduced in z3c.template 1.2.0.
-
-* Don't do rendering in pagelet's __call__ method when request is a redirection.
-
-* Add sphinx-based HTML documentation building part to the buildout.
-
-
-1.0.2 (2008-01-21)
-------------------
-
-* Added a `form.zcml` which can be included to have a template for
-  ``PageletAddForm``, ``PageletEditForm`` and ``PageletDisplayForm``.
-
-
-1.0.1 (2007-10-08)
-------------------
-
-* Added ``update()`` and ``render()`` method to ``IPagelet`` which was
-  not specified but used.
-
-* Fixed a infinite recursion bug when a layout template was registered for "*"
-  but no content template was registered for a pagelet.

Copied: z3c.pagelet/tags/1.2.0/CHANGES.txt (from rev 103299, z3c.pagelet/trunk/CHANGES.txt)
===================================================================
--- z3c.pagelet/tags/1.2.0/CHANGES.txt	                        (rev 0)
+++ z3c.pagelet/tags/1.2.0/CHANGES.txt	2009-08-27 16:34:19 UTC (rev 103307)
@@ -0,0 +1,55 @@
+=======
+CHANGES
+=======
+
+1.2.0 (2009-08-27)
+------------------
+
+- Fix untrusted redirect to google.com in tests. It's now forbidden by default
+  by newer zope.publisher versions.
+
+- Change ``zope.app.publisher`` dependency to new ``zope.browserpage``, as it
+  has much less dependencies.
+
+1.1.0 (2009-05-28)
+------------------
+
+* Got rid of dependency on ``zope.app.component`` by requiring
+  ``zope.component >= 3.7``.
+
+* Removed hard dependency on ``zope.formlib``: the pagelet forms now
+  only get defined when ``zope.formlib`` is available. Tests still
+  depend on ``zope.formlib``, so it got a test dependency.
+
+* Made sure long_description renders fine on pypi.
+
+
+1.0.3 (2009-02-27)
+------------------
+
+* Allow use of ``z3c.pt`` using ``z3c.ptcompat`` compatibility layer.
+
+* Add support for context-specific layout and content template lookup,
+  using (view, request, context) discriminator. This is compatible with
+  context-specific templates introduced in z3c.template 1.2.0.
+
+* Don't do rendering in pagelet's __call__ method when request is a redirection.
+
+* Add sphinx-based HTML documentation building part to the buildout.
+
+
+1.0.2 (2008-01-21)
+------------------
+
+* Added a `form.zcml` which can be included to have a template for
+  ``PageletAddForm``, ``PageletEditForm`` and ``PageletDisplayForm``.
+
+
+1.0.1 (2007-10-08)
+------------------
+
+* Added ``update()`` and ``render()`` method to ``IPagelet`` which was
+  not specified but used.
+
+* Fixed a infinite recursion bug when a layout template was registered for "*"
+  but no content template was registered for a pagelet.

Deleted: z3c.pagelet/tags/1.2.0/setup.py
===================================================================
--- z3c.pagelet/trunk/setup.py	2009-08-27 15:20:32 UTC (rev 103295)
+++ z3c.pagelet/tags/1.2.0/setup.py	2009-08-27 16:34:19 UTC (rev 103307)
@@ -1,85 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2007-2009 Zope Foundation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Setup
-
-$Id$
-"""
-import os
-import xml.sax.saxutils
-from setuptools import setup, find_packages
-
-def read(*rnames):
-    return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
-
-version = '1.1.1dev'
-
-setup(
-    name='z3c.pagelet',
-    version=version,
-    author = "Roger Ineichen and the Zope Community",
-    author_email = "zope-dev at zope.org",
-    description = "Pagelets are way to specify a template without the O-wrap.",
-    long_description=(
-        read('README.txt')
-        + '\n\n' +
-        read('src', 'z3c', 'pagelet', 'README.txt')
-        + '\n\n' +
-        read('CHANGES.txt')
-        ),
-    license = "ZPL 2.1",
-    keywords = "zope3 template pagelet layout zpt pagetemplate",
-    classifiers = [
-        'Development Status :: 5 - Production/Stable',
-        'Environment :: Web Environment',
-        'Intended Audience :: Developers',
-        'License :: OSI Approved :: Zope Public License',
-        'Programming Language :: Python',
-        'Natural Language :: English',
-        'Operating System :: OS Independent',
-        'Topic :: Internet :: WWW/HTTP',
-        'Framework :: Zope3'],
-    url = 'http://pypi.python.org/pypi/z3c.pagelet',
-    packages = find_packages('src'),
-    package_dir = {'':'src'},
-    namespace_packages = ['z3c'],
-    extras_require = dict(
-        test = ['zope.app.testing',
-                'zope.app.form',
-                'zope.testing',
-                'zope.traversing',
-                'lxml>=2.1.1',
-                'z3c.pt>=1.0b4',
-                'z3c.ptcompat',
-                'zope.app.security',
-                'zope.formlib',
-                ],
-        docs = ['z3c.recipe.sphinxdoc'],
-        ),
-    install_requires = [
-        'setuptools',
-        'z3c.template>=1.2.0',
-        'z3c.ptcompat',
-         # TODO: this is only needed for ZCML directives, so can copy
-        'zope.app.publisher', # things we use from there and get rid of the dependencies.
-        'zope.component>=3.7.0',
-        'zope.configuration',
-        'zope.contentprovider',
-        'zope.interface',
-        'zope.publisher',
-        'zope.schema',
-        'zope.security',
-        ],
-    include_package_data = True,
-    zip_safe = False,
-    )

Copied: z3c.pagelet/tags/1.2.0/setup.py (from rev 103299, z3c.pagelet/trunk/setup.py)
===================================================================
--- z3c.pagelet/tags/1.2.0/setup.py	                        (rev 0)
+++ z3c.pagelet/tags/1.2.0/setup.py	2009-08-27 16:34:19 UTC (rev 103307)
@@ -0,0 +1,85 @@
+##############################################################################
+#
+# Copyright (c) 2007-2009 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Setup
+
+$Id$
+"""
+import os
+import xml.sax.saxutils
+from setuptools import setup, find_packages
+
+def read(*rnames):
+    return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
+
+version = '1.2.0'
+
+setup(
+    name='z3c.pagelet',
+    version=version,
+    author = "Roger Ineichen and the Zope Community",
+    author_email = "zope-dev at zope.org",
+    description = "Pagelets are way to specify a template without the O-wrap.",
+    long_description=(
+        read('README.txt')
+        + '\n\n' +
+        read('src', 'z3c', 'pagelet', 'README.txt')
+        + '\n\n' +
+        read('CHANGES.txt')
+        ),
+    license = "ZPL 2.1",
+    keywords = "zope3 template pagelet layout zpt pagetemplate",
+    classifiers = [
+        'Development Status :: 5 - Production/Stable',
+        'Environment :: Web Environment',
+        'Intended Audience :: Developers',
+        'License :: OSI Approved :: Zope Public License',
+        'Programming Language :: Python',
+        'Natural Language :: English',
+        'Operating System :: OS Independent',
+        'Topic :: Internet :: WWW/HTTP',
+        'Framework :: Zope3'],
+    url = 'http://pypi.python.org/pypi/z3c.pagelet',
+    packages = find_packages('src'),
+    package_dir = {'':'src'},
+    namespace_packages = ['z3c'],
+    extras_require = dict(
+        test = ['zope.app.testing',
+                'zope.app.form',
+                'zope.testing',
+                'zope.traversing',
+                'lxml>=2.1.1',
+                'z3c.pt>=1.0b4',
+                'z3c.ptcompat',
+                'zope.app.security',
+                'zope.formlib',
+                ],
+        docs = ['z3c.recipe.sphinxdoc'],
+        ),
+    install_requires = [
+        'setuptools',
+        'z3c.template>=1.2.0',
+        'z3c.ptcompat',
+         # TODO: this is only needed for ZCML directives, so can copy
+        'zope.browserpage', # things we use from there and get rid of the dependencies.
+        'zope.component>=3.7.0',
+        'zope.configuration',
+        'zope.contentprovider',
+        'zope.interface',
+        'zope.publisher',
+        'zope.schema',
+        'zope.security',
+        ],
+    include_package_data = True,
+    zip_safe = False,
+    )

Deleted: z3c.pagelet/tags/1.2.0/src/z3c/pagelet/README.txt
===================================================================
--- z3c.pagelet/trunk/src/z3c/pagelet/README.txt	2009-08-27 15:20:32 UTC (rev 103295)
+++ z3c.pagelet/tags/1.2.0/src/z3c/pagelet/README.txt	2009-08-27 16:34:19 UTC (rev 103307)
@@ -1,469 +0,0 @@
-========
-Pagelets
-========
-
-.. contents::
-
-This package provides a very flexible base implementation that can be used
-to write view components which can be higly customized later in custom projects.
-This is needed if you have to write reusable components like those needed
-in a framework. Pagelets are BrowserPages made differently and can be used
-to replace them.
-
-What does this mean?
-
-We separate the python view code from the template implementation. And we also
-separate the template in at least two different templates - the content
-template and the layout template.
-
-This package uses z3c.template and offers an implementaton for this
-template pattern. Additionaly this package offers a ``pagelet`` directive
-wich can be used to register pagelets.
-
-Pagelets are views which can be called and support the update and render
-pattern.
-
-
-How do they work
-----------------
-
-A pagelet returns the rendered content without layout in the render method and
-returns the layout code if we call it. See also z3c.template which shows
-how the template works. These samples will only show how the base implementation
-located in the z3c.pagelet.browser module get used.
-
-
-BrowserPagelet
---------------
-
-The base implementation called BrowserPagelet offers builtin __call__ and
-render methods which provide the different template lookups. Take a look at the
-BrowserPagelet class located in z3c.pagelet.browser and you can see that the render
-method returns a IContentTemplate and the __call__ method a ILayoutTemplate
-defined in the z3c.layout package.
-
-  >>> import os, tempfile
-  >>> temp_dir = tempfile.mkdtemp()
-
-  >>> import zope.interface
-  >>> import zope.component
-  >>> from z3c.pagelet import interfaces
-  >>> from z3c.pagelet import browser
-
-We start by defining a page template rendering the pagelet content.
-
-  >>> contentTemplate = os.path.join(temp_dir, 'contentTemplate.pt')
-  >>> open(contentTemplate, 'w').write('''
-  ...   <div class="content">
-  ...     my template content
-  ...   </div>
-  ... ''')
-
-And we also define a layout template rendering the layout for a pagelet.
-This template will call the render method from a pagelet:
-
-  >>> layoutTemplate = os.path.join(temp_dir, 'layoutTemplate.pt')
-  >>> open(layoutTemplate, 'w').write('''
-  ...   <html>
-  ...     <body>
-  ...       <div class="layout" tal:content="structure view/render">
-  ...         here comes the content
-  ...       </div>
-  ...     </body>
-  ...   </html>
-  ... ''')
-
-Let's now register the template for the view and the request. We use the
-TemplateFactory directly from the z3c.template package. This is commonly done
-using the ZCML directive called ``z3c:template``. Note that we do use the
-generic Interface as the view base interface to register the template. This
-allows us to register a more specific template in the next sample:
-
-  >>> from zope.publisher.interfaces.browser import IDefaultBrowserLayer
-  >>> from z3c.template.interfaces import IContentTemplate
-  >>> from z3c.template.template import TemplateFactory
-  >>> factory = TemplateFactory(contentTemplate, 'text/html')
-  >>> zope.component.provideAdapter(
-  ...     factory, (zope.interface.Interface, IDefaultBrowserLayer),
-  ...     IContentTemplate)
-
-And register the layout template using the ``Interface`` as registration base:
-
-  >>> from z3c.template.interfaces import ILayoutTemplate
-  >>> factory = TemplateFactory(layoutTemplate, 'text/html')
-  >>> zope.component.provideAdapter(factory,
-  ...     (zope.interface.Interface, IDefaultBrowserLayer), ILayoutTemplate)
-
-Now define a view marker interface. Such a marker interface is used to let
-us register our templates:
-
-  >>> class IMyView(zope.interface.Interface):
-  ...     pass
-
-And we define a view class inherited from BrowserPagelet and implementing the
-view marker interface:
-
-  >>> class MyView(browser.BrowserPagelet):
-  ...     zope.interface.implements(IMyView)
-
-Now test the view class providing the view and check the output:
-
-  >>> from zope.publisher.browser import TestRequest
-  >>> request = TestRequest()
-  >>> myView = MyView(root, request)
-  >>> print myView()
-  <html>
-    <body>
-      <div class="layout">
-        <div class="content">
-          my template content
-        </div>
-      </div>
-    </body>
-  </html>
-
-You can see the render method generates only the content:
-
-  >>> print myView.render()
-  <div class="content">
-    my template content
-  </div>
-
-
-Redirection
------------
-
-The pagelet doesn't bother rendering itself and its layout when request is a
-redirection as the rendering doesn't make any sense with browser requests in
-that case. Let's create a view that does a redirection in its update method.
-
-  >>> class RedirectingView(MyView):
-  ...     def update(self):
-  ...         self.request.response.redirect('http://www.google.com/')
-
-It will return an empty string when called as a browser page.
-
-  >>> redirectRequest = TestRequest()
-  >>> redirectView = RedirectingView(root, redirectRequest)
-  >>> redirectView() == ''
-  True
-
-However, the ``render`` method will render pagelet's template as usual:
-
-  >>> print redirectView.render()
-  <div class="content">
-    my template content
-  </div>
-
-
-PageletRenderer
----------------
-
-There is also a standard pattern for calling the render method on pagelet.
-Using the pagelet renderer which is a IContentProvider makes it possible to
-reuse existing layout template without the pagelet. If you want to reuse a
-layout template without a pagelet you simply have to provide another content
-provider. It's flexible isn't it? As next let's show a sample using the
-pagelet renderer.
-
-We define a new layout template using the content provider called ```pagelet``
-
-
-  >>> providerLayout = os.path.join(temp_dir, 'providerLayout.pt')
-  >>> open(providerLayout, 'w').write('''
-  ...   <html>
-  ...     <body>
-  ...       <div class="layout" tal:content="structure provider:pagelet">
-  ...         here comes the content
-  ...       </div>
-  ...     </body>
-  ...   </html>
-  ... ''')
-
-and register them. Now we use the specific interface defined in the view:
-
-  >>> factory = TemplateFactory(providerLayout, 'text/html')
-  >>> zope.component.provideAdapter(factory,
-  ...     (zope.interface.Interface, IDefaultBrowserLayer), ILayoutTemplate)
-
-Now let's call the view:
-
-  >>> print myView()
-  Traceback (most recent call last):
-  ...
-  ContentProviderLookupError: pagelet
-
-That's right, we need to register the content provider ``pagelet`` before we
-can use it.
-
-  >>> from zope.contentprovider.interfaces import IContentProvider
-  >>> from z3c.pagelet import provider
-  >>> zope.component.provideAdapter(provider.PageletRenderer,
-  ...     provides=IContentProvider, name='pagelet')
-
-Now let's call the view again:
-
-  >>> print myView()
-  <html>
-    <body>
-      <div class="layout">
-        <div class="content">
-          my template content
-        </div>
-      </div>
-    </body>
-  </html>
-
-
-Context-specific templates
---------------------------
-
-Pagelets are also able to lookup templates using their context object
-as an additional discriminator, via (self, self.request, self.context)
-lookup. It's useful when you want to provide a custom template for
-some specific content objects. Let's check that out.
-
-First, let's define a custom content type and make an object to work with:
-
-  >>> class IContent(zope.interface.Interface):
-  ...     pass
-  >>> class Content(object):
-  ...     zope.interface.implements(IContent)
-
-  >>> content = Content()
-
-Let's use our view class we defined earlier. Currently, it will use
-the layout and content templates we defined for (view, request) before:
-
-  >>> myView = MyView(content, request)
-  >>> print myView()
-  <html>
-    <body>
-      <div class="layout">
-        <div class="content">
-          my template content
-        </div>
-      </div>
-    </body>
-  </html>
-
-Let's create context-specific layout and content templates and register
-them for our IContent interface:
-
-  >>> contextLayoutTemplate = os.path.join(temp_dir, 'contextLayoutTemplate.pt')
-  >>> open(contextLayoutTemplate, 'w').write('''
-  ...   <html>
-  ...     <body>
-  ...       <div class="context-layout" tal:content="structure provider:pagelet">
-  ...         here comes the context-specific content
-  ...       </div>
-  ...     </body>
-  ...   </html>
-  ... ''')
-  >>> factory = TemplateFactory(contextLayoutTemplate, 'text/html')
-  >>> zope.component.provideAdapter(
-  ...     factory, (zope.interface.Interface, IDefaultBrowserLayer, IContent),
-  ...     ILayoutTemplate)
-
-  >>> contextContentTemplate = os.path.join(temp_dir, 'contextContentTemplate.pt')
-  >>> open(contextContentTemplate, 'w').write('''
-  ...   <div class="context-content">
-  ...     my context-specific template content
-  ...   </div>
-  ... ''')
-  >>> factory = TemplateFactory(contextContentTemplate, 'text/html')
-  >>> zope.component.provideAdapter(
-  ...     factory, (zope.interface.Interface, IDefaultBrowserLayer, IContent),
-  ...     IContentTemplate)
-
-Now, our view should use context-specific templates for rendering:
-
-  >>> print myView()
-  <html>
-    <body>
-      <div class="context-layout">
-        <div class="context-content">
-          my context-specific template content
-        </div>
-      </div>
-    </body>
-  </html>
-
-
-Add, Edit and Display forms (formlib)
--------------------------------------
-
-What would the pagelet be without any formlib based implementations?
-We offer base implementations for add, edit and display forms based on
-the formlib. **Note:** To make sure these classes get defined, you
-should have ``zope.formlib`` already installed, as ``z3c.pagelet``
-does not directly depend on ``zope.formlib`` because there are other
-form libraries.
-
-For the next tests we provide a generic form template
-like those used in formlib. This template is registered within this package
-as a default for the formlib based mixin classes:
-
-  >>> from z3c import pagelet
-  >>> baseDir = os.path.split(pagelet.__file__)[0]
-  >>> formTemplate = os.path.join(baseDir, 'form.pt')
-  >>> factory = TemplateFactory(formTemplate, 'text/html')
-  >>> zope.component.provideAdapter(
-  ...     factory,
-  ...     (interfaces.IPageletForm, IDefaultBrowserLayer), IContentTemplate)
-
-And we define a new interface including a text attribute:
-
-  >>> import zope.schema
-  >>> class IDocument(zope.interface.Interface):
-  ...     """A document."""
-  ...     text = zope.schema.TextLine(title=u'Text', description=u'Text attr.')
-
-Also define a content object which implements the interface:
-
-  >>> class Document(object):
-  ...     zope.interface.implements(IDocument)
-  ...     text = None
-  >>> document = Document()
-
-PageletAddForm
-~~~~~~~~~~~~~~
-
-Now let's define an add from based on the PageletAddForm class:
-
-  >>> from zope.formlib import form
-  >>> class MyAddForm(browser.PageletAddForm):
-  ...     form_fields = form.Fields(IDocument)
-  ...     def createAndAdd(self, data):
-  ...         title = data.get('title', u'')
-  ...         doc = Document()
-  ...         doc.title = title
-  ...         root['document'] = doc
-  ...         return doc
-
-Now render the form:
-
-  >>> from z3c.ptcompat.testing import render
-
-  >>> addForm = MyAddForm(root, request)
-  >>> print addForm()
-  <html>
-    <body>
-      <div class="layout">
-        <form action="http://127.0.0.1" method="post"
-              enctype="multipart/form-data" class="edit-form"
-              id="zc.page.browser_form">
-          <table class="form-fields">
-            <tr>
-              <td class="label">
-                <label for="form.text">
-                <span class="required">*</span><span>Text</span>
-                </label>
-              </td>
-              <td class="field">
-                <div class="form-fields-help"
-                     id="field-help-for-form.text">Text attr.</div>
-                <div class="widget"><input class="textType" id="form.text"
-                     name="form.text" size="20" type="text" value=""  /></div>
-              </td>
-            </tr>
-          </table>
-        <div class="form-controls">
-          <input type="submit" id="form.actions.add" name="form.actions.add"
-                 value="Add" class="button" />
-        </div>
-      </form>
-    </div>
-    </body>
-  </html>
-
-
-PageletEditForm
-~~~~~~~~~~~~~~~
-
-Now let's define an edit form based on the PageletEditForm class:
-
-  >>> class MyEditForm(browser.PageletEditForm):
-  ...     form_fields = form.Fields(IDocument)
-
-and render the form:
-
-  >>> document.text = u'foo'
-  >>> editForm = MyEditForm(document, request)
-  >>> print editForm()
-  <html>
-    <body>
-      <div class="layout">
-        <form action="http://127.0.0.1" method="post"
-              enctype="multipart/form-data" class="edit-form"
-              id="zc.page.browser_form">
-          <table class="form-fields">
-              <tr>
-                <td class="label">
-                  <label for="form.text">
-                  <span class="required">*</span><span>Text</span>
-                  </label>
-                </td>
-                <td class="field">
-                  <div class="form-fields-help"
-                       id="field-help-for-form.text">Text attr.</div>
-                  <div class="widget"><input class="textType" id="form.text"
-                       name="form.text" size="20" type="text" value="foo"
-                       /></div>
-                </td>
-              </tr>
-          </table>
-          <div class="form-controls">
-            <input type="submit" id="form.actions.apply"
-                   name="form.actions.apply" value="Apply" class="button" />
-          </div>
-        </form>
-      </div>
-    </body>
-  </html>
-
-
-PageletDisplayForm
-~~~~~~~~~~~~~~~~~~
-
-Now let's define a display form based on the PageletDisplayForm class...
-
-  >>> class MyDisplayForm(browser.PageletDisplayForm):
-  ...     form_fields = form.Fields(IDocument)
-
-and render the form:
-
-  >>> document.text = u'foo'
-  >>> displayForm = MyDisplayForm(document, request)
-  >>> print displayForm()
-  <html>
-    <body>
-      <div class="layout">
-        <form action="http://127.0.0.1" method="post"
-              enctype="multipart/form-data" class="edit-form"
-              id="zc.page.browser_form">
-          <table class="form-fields">
-              <tr>
-                <td class="label">
-                  <label for="form.text">
-                  <span>Text</span>
-                  </label>
-                </td>
-                <td class="field">
-                  <div class="form-fields-help"
-                       id="field-help-for-form.text">Text attr.</div>
-                  <div class="widget">foo</div>
-                </td>
-              </tr>
-          </table>
-        </form>
-      </div>
-    </body>
-  </html>
-
-
-Cleanup
--------
-
-  >>> import shutil
-  >>> shutil.rmtree(temp_dir)

Copied: z3c.pagelet/tags/1.2.0/src/z3c/pagelet/README.txt (from rev 103296, z3c.pagelet/trunk/src/z3c/pagelet/README.txt)
===================================================================
--- z3c.pagelet/tags/1.2.0/src/z3c/pagelet/README.txt	                        (rev 0)
+++ z3c.pagelet/tags/1.2.0/src/z3c/pagelet/README.txt	2009-08-27 16:34:19 UTC (rev 103307)
@@ -0,0 +1,469 @@
+========
+Pagelets
+========
+
+.. contents::
+
+This package provides a very flexible base implementation that can be used
+to write view components which can be higly customized later in custom projects.
+This is needed if you have to write reusable components like those needed
+in a framework. Pagelets are BrowserPages made differently and can be used
+to replace them.
+
+What does this mean?
+
+We separate the python view code from the template implementation. And we also
+separate the template in at least two different templates - the content
+template and the layout template.
+
+This package uses z3c.template and offers an implementaton for this
+template pattern. Additionaly this package offers a ``pagelet`` directive
+wich can be used to register pagelets.
+
+Pagelets are views which can be called and support the update and render
+pattern.
+
+
+How do they work
+----------------
+
+A pagelet returns the rendered content without layout in the render method and
+returns the layout code if we call it. See also z3c.template which shows
+how the template works. These samples will only show how the base implementation
+located in the z3c.pagelet.browser module get used.
+
+
+BrowserPagelet
+--------------
+
+The base implementation called BrowserPagelet offers builtin __call__ and
+render methods which provide the different template lookups. Take a look at the
+BrowserPagelet class located in z3c.pagelet.browser and you can see that the render
+method returns a IContentTemplate and the __call__ method a ILayoutTemplate
+defined in the z3c.layout package.
+
+  >>> import os, tempfile
+  >>> temp_dir = tempfile.mkdtemp()
+
+  >>> import zope.interface
+  >>> import zope.component
+  >>> from z3c.pagelet import interfaces
+  >>> from z3c.pagelet import browser
+
+We start by defining a page template rendering the pagelet content.
+
+  >>> contentTemplate = os.path.join(temp_dir, 'contentTemplate.pt')
+  >>> open(contentTemplate, 'w').write('''
+  ...   <div class="content">
+  ...     my template content
+  ...   </div>
+  ... ''')
+
+And we also define a layout template rendering the layout for a pagelet.
+This template will call the render method from a pagelet:
+
+  >>> layoutTemplate = os.path.join(temp_dir, 'layoutTemplate.pt')
+  >>> open(layoutTemplate, 'w').write('''
+  ...   <html>
+  ...     <body>
+  ...       <div class="layout" tal:content="structure view/render">
+  ...         here comes the content
+  ...       </div>
+  ...     </body>
+  ...   </html>
+  ... ''')
+
+Let's now register the template for the view and the request. We use the
+TemplateFactory directly from the z3c.template package. This is commonly done
+using the ZCML directive called ``z3c:template``. Note that we do use the
+generic Interface as the view base interface to register the template. This
+allows us to register a more specific template in the next sample:
+
+  >>> from zope.publisher.interfaces.browser import IDefaultBrowserLayer
+  >>> from z3c.template.interfaces import IContentTemplate
+  >>> from z3c.template.template import TemplateFactory
+  >>> factory = TemplateFactory(contentTemplate, 'text/html')
+  >>> zope.component.provideAdapter(
+  ...     factory, (zope.interface.Interface, IDefaultBrowserLayer),
+  ...     IContentTemplate)
+
+And register the layout template using the ``Interface`` as registration base:
+
+  >>> from z3c.template.interfaces import ILayoutTemplate
+  >>> factory = TemplateFactory(layoutTemplate, 'text/html')
+  >>> zope.component.provideAdapter(factory,
+  ...     (zope.interface.Interface, IDefaultBrowserLayer), ILayoutTemplate)
+
+Now define a view marker interface. Such a marker interface is used to let
+us register our templates:
+
+  >>> class IMyView(zope.interface.Interface):
+  ...     pass
+
+And we define a view class inherited from BrowserPagelet and implementing the
+view marker interface:
+
+  >>> class MyView(browser.BrowserPagelet):
+  ...     zope.interface.implements(IMyView)
+
+Now test the view class providing the view and check the output:
+
+  >>> from zope.publisher.browser import TestRequest
+  >>> request = TestRequest()
+  >>> myView = MyView(root, request)
+  >>> print myView()
+  <html>
+    <body>
+      <div class="layout">
+        <div class="content">
+          my template content
+        </div>
+      </div>
+    </body>
+  </html>
+
+You can see the render method generates only the content:
+
+  >>> print myView.render()
+  <div class="content">
+    my template content
+  </div>
+
+
+Redirection
+-----------
+
+The pagelet doesn't bother rendering itself and its layout when request is a
+redirection as the rendering doesn't make any sense with browser requests in
+that case. Let's create a view that does a redirection in its update method.
+
+  >>> class RedirectingView(MyView):
+  ...     def update(self):
+  ...         self.request.response.redirect('.')
+
+It will return an empty string when called as a browser page.
+
+  >>> redirectRequest = TestRequest()
+  >>> redirectView = RedirectingView(root, redirectRequest)
+  >>> redirectView() == ''
+  True
+
+However, the ``render`` method will render pagelet's template as usual:
+
+  >>> print redirectView.render()
+  <div class="content">
+    my template content
+  </div>
+
+
+PageletRenderer
+---------------
+
+There is also a standard pattern for calling the render method on pagelet.
+Using the pagelet renderer which is a IContentProvider makes it possible to
+reuse existing layout template without the pagelet. If you want to reuse a
+layout template without a pagelet you simply have to provide another content
+provider. It's flexible isn't it? As next let's show a sample using the
+pagelet renderer.
+
+We define a new layout template using the content provider called ```pagelet``
+
+
+  >>> providerLayout = os.path.join(temp_dir, 'providerLayout.pt')
+  >>> open(providerLayout, 'w').write('''
+  ...   <html>
+  ...     <body>
+  ...       <div class="layout" tal:content="structure provider:pagelet">
+  ...         here comes the content
+  ...       </div>
+  ...     </body>
+  ...   </html>
+  ... ''')
+
+and register them. Now we use the specific interface defined in the view:
+
+  >>> factory = TemplateFactory(providerLayout, 'text/html')
+  >>> zope.component.provideAdapter(factory,
+  ...     (zope.interface.Interface, IDefaultBrowserLayer), ILayoutTemplate)
+
+Now let's call the view:
+
+  >>> print myView()
+  Traceback (most recent call last):
+  ...
+  ContentProviderLookupError: pagelet
+
+That's right, we need to register the content provider ``pagelet`` before we
+can use it.
+
+  >>> from zope.contentprovider.interfaces import IContentProvider
+  >>> from z3c.pagelet import provider
+  >>> zope.component.provideAdapter(provider.PageletRenderer,
+  ...     provides=IContentProvider, name='pagelet')
+
+Now let's call the view again:
+
+  >>> print myView()
+  <html>
+    <body>
+      <div class="layout">
+        <div class="content">
+          my template content
+        </div>
+      </div>
+    </body>
+  </html>
+
+
+Context-specific templates
+--------------------------
+
+Pagelets are also able to lookup templates using their context object
+as an additional discriminator, via (self, self.request, self.context)
+lookup. It's useful when you want to provide a custom template for
+some specific content objects. Let's check that out.
+
+First, let's define a custom content type and make an object to work with:
+
+  >>> class IContent(zope.interface.Interface):
+  ...     pass
+  >>> class Content(object):
+  ...     zope.interface.implements(IContent)
+
+  >>> content = Content()
+
+Let's use our view class we defined earlier. Currently, it will use
+the layout and content templates we defined for (view, request) before:
+
+  >>> myView = MyView(content, request)
+  >>> print myView()
+  <html>
+    <body>
+      <div class="layout">
+        <div class="content">
+          my template content
+        </div>
+      </div>
+    </body>
+  </html>
+
+Let's create context-specific layout and content templates and register
+them for our IContent interface:
+
+  >>> contextLayoutTemplate = os.path.join(temp_dir, 'contextLayoutTemplate.pt')
+  >>> open(contextLayoutTemplate, 'w').write('''
+  ...   <html>
+  ...     <body>
+  ...       <div class="context-layout" tal:content="structure provider:pagelet">
+  ...         here comes the context-specific content
+  ...       </div>
+  ...     </body>
+  ...   </html>
+  ... ''')
+  >>> factory = TemplateFactory(contextLayoutTemplate, 'text/html')
+  >>> zope.component.provideAdapter(
+  ...     factory, (zope.interface.Interface, IDefaultBrowserLayer, IContent),
+  ...     ILayoutTemplate)
+
+  >>> contextContentTemplate = os.path.join(temp_dir, 'contextContentTemplate.pt')
+  >>> open(contextContentTemplate, 'w').write('''
+  ...   <div class="context-content">
+  ...     my context-specific template content
+  ...   </div>
+  ... ''')
+  >>> factory = TemplateFactory(contextContentTemplate, 'text/html')
+  >>> zope.component.provideAdapter(
+  ...     factory, (zope.interface.Interface, IDefaultBrowserLayer, IContent),
+  ...     IContentTemplate)
+
+Now, our view should use context-specific templates for rendering:
+
+  >>> print myView()
+  <html>
+    <body>
+      <div class="context-layout">
+        <div class="context-content">
+          my context-specific template content
+        </div>
+      </div>
+    </body>
+  </html>
+
+
+Add, Edit and Display forms (formlib)
+-------------------------------------
+
+What would the pagelet be without any formlib based implementations?
+We offer base implementations for add, edit and display forms based on
+the formlib. **Note:** To make sure these classes get defined, you
+should have ``zope.formlib`` already installed, as ``z3c.pagelet``
+does not directly depend on ``zope.formlib`` because there are other
+form libraries.
+
+For the next tests we provide a generic form template
+like those used in formlib. This template is registered within this package
+as a default for the formlib based mixin classes:
+
+  >>> from z3c import pagelet
+  >>> baseDir = os.path.split(pagelet.__file__)[0]
+  >>> formTemplate = os.path.join(baseDir, 'form.pt')
+  >>> factory = TemplateFactory(formTemplate, 'text/html')
+  >>> zope.component.provideAdapter(
+  ...     factory,
+  ...     (interfaces.IPageletForm, IDefaultBrowserLayer), IContentTemplate)
+
+And we define a new interface including a text attribute:
+
+  >>> import zope.schema
+  >>> class IDocument(zope.interface.Interface):
+  ...     """A document."""
+  ...     text = zope.schema.TextLine(title=u'Text', description=u'Text attr.')
+
+Also define a content object which implements the interface:
+
+  >>> class Document(object):
+  ...     zope.interface.implements(IDocument)
+  ...     text = None
+  >>> document = Document()
+
+PageletAddForm
+~~~~~~~~~~~~~~
+
+Now let's define an add from based on the PageletAddForm class:
+
+  >>> from zope.formlib import form
+  >>> class MyAddForm(browser.PageletAddForm):
+  ...     form_fields = form.Fields(IDocument)
+  ...     def createAndAdd(self, data):
+  ...         title = data.get('title', u'')
+  ...         doc = Document()
+  ...         doc.title = title
+  ...         root['document'] = doc
+  ...         return doc
+
+Now render the form:
+
+  >>> from z3c.ptcompat.testing import render
+
+  >>> addForm = MyAddForm(root, request)
+  >>> print addForm()
+  <html>
+    <body>
+      <div class="layout">
+        <form action="http://127.0.0.1" method="post"
+              enctype="multipart/form-data" class="edit-form"
+              id="zc.page.browser_form">
+          <table class="form-fields">
+            <tr>
+              <td class="label">
+                <label for="form.text">
+                <span class="required">*</span><span>Text</span>
+                </label>
+              </td>
+              <td class="field">
+                <div class="form-fields-help"
+                     id="field-help-for-form.text">Text attr.</div>
+                <div class="widget"><input class="textType" id="form.text"
+                     name="form.text" size="20" type="text" value=""  /></div>
+              </td>
+            </tr>
+          </table>
+        <div class="form-controls">
+          <input type="submit" id="form.actions.add" name="form.actions.add"
+                 value="Add" class="button" />
+        </div>
+      </form>
+    </div>
+    </body>
+  </html>
+
+
+PageletEditForm
+~~~~~~~~~~~~~~~
+
+Now let's define an edit form based on the PageletEditForm class:
+
+  >>> class MyEditForm(browser.PageletEditForm):
+  ...     form_fields = form.Fields(IDocument)
+
+and render the form:
+
+  >>> document.text = u'foo'
+  >>> editForm = MyEditForm(document, request)
+  >>> print editForm()
+  <html>
+    <body>
+      <div class="layout">
+        <form action="http://127.0.0.1" method="post"
+              enctype="multipart/form-data" class="edit-form"
+              id="zc.page.browser_form">
+          <table class="form-fields">
+              <tr>
+                <td class="label">
+                  <label for="form.text">
+                  <span class="required">*</span><span>Text</span>
+                  </label>
+                </td>
+                <td class="field">
+                  <div class="form-fields-help"
+                       id="field-help-for-form.text">Text attr.</div>
+                  <div class="widget"><input class="textType" id="form.text"
+                       name="form.text" size="20" type="text" value="foo"
+                       /></div>
+                </td>
+              </tr>
+          </table>
+          <div class="form-controls">
+            <input type="submit" id="form.actions.apply"
+                   name="form.actions.apply" value="Apply" class="button" />
+          </div>
+        </form>
+      </div>
+    </body>
+  </html>
+
+
+PageletDisplayForm
+~~~~~~~~~~~~~~~~~~
+
+Now let's define a display form based on the PageletDisplayForm class...
+
+  >>> class MyDisplayForm(browser.PageletDisplayForm):
+  ...     form_fields = form.Fields(IDocument)
+
+and render the form:
+
+  >>> document.text = u'foo'
+  >>> displayForm = MyDisplayForm(document, request)
+  >>> print displayForm()
+  <html>
+    <body>
+      <div class="layout">
+        <form action="http://127.0.0.1" method="post"
+              enctype="multipart/form-data" class="edit-form"
+              id="zc.page.browser_form">
+          <table class="form-fields">
+              <tr>
+                <td class="label">
+                  <label for="form.text">
+                  <span>Text</span>
+                  </label>
+                </td>
+                <td class="field">
+                  <div class="form-fields-help"
+                       id="field-help-for-form.text">Text attr.</div>
+                  <div class="widget">foo</div>
+                </td>
+              </tr>
+          </table>
+        </form>
+      </div>
+    </body>
+  </html>
+
+
+Cleanup
+-------
+
+  >>> import shutil
+  >>> shutil.rmtree(temp_dir)

Deleted: z3c.pagelet/tags/1.2.0/src/z3c/pagelet/zcml.py
===================================================================
--- z3c.pagelet/trunk/src/z3c/pagelet/zcml.py	2009-08-27 15:20:32 UTC (rev 103295)
+++ z3c.pagelet/tags/1.2.0/src/z3c/pagelet/zcml.py	2009-08-27 16:34:19 UTC (rev 103307)
@@ -1,136 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2005 Zope Foundation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""
-$Id$
-"""
-__docformat__ = "reStructuredText"
-
-import zope.interface
-import zope.component
-import zope.component.zcml
-import zope.schema
-import zope.configuration.fields
-import zope.security.checker
-import zope.security.zcml
-from zope.configuration.exceptions import ConfigurationError
-from zope.publisher.interfaces.browser import IDefaultBrowserLayer
-
-from zope.app.publisher.browser import viewmeta
-
-from z3c.pagelet import interfaces
-from z3c.pagelet import browser
-
-
-class IPageletDirective(zope.component.zcml.IBasicViewInformation):
-    """A directive to register a new pagelet.
-
-    The pagelet directive also supports an undefined set of keyword arguments
-    that are set as attributes on the pagelet after creation.
-    """
-
-    name = zope.schema.TextLine(
-        title=u"The name of the pagelet.",
-        description=u"The name shows up in URLs/paths. For example 'foo'.",
-        required=True)
-
-    class_ = zope.configuration.fields.GlobalObject(
-        title=u"Class",
-        description=u"A class that provides attributes used by the pagelet.",
-        required=True,
-        )
-
-    permission = zope.security.zcml.Permission(
-        title=u"Permission",
-        description=u"The permission needed to use the pagelet.",
-        required=True
-        )
-
-    for_ = zope.configuration.fields.GlobalObject(
-        title=u"Context",
-        description=u"The content interface or class this pagelet is for.",
-        required=False
-        )
-
-    provides = zope.configuration.fields.GlobalInterface(
-        title=u"The interface this pagelets provides.",
-        description=u"""
-        A pagelet can provide an interface.  This would be used for
-        views that support other views.""",
-        required=False,
-        default=interfaces.IPagelet,
-        )
-
-
-# Arbitrary keys and values are allowed to be passed to the pagelet.
-IPageletDirective.setTaggedValue('keyword_arguments', True)
-
-
-# pagelet directive
-def pageletDirective(
-    _context, class_, name, permission, for_=zope.interface.Interface,
-    layer=IDefaultBrowserLayer, provides=interfaces.IPagelet,
-    allowed_interface=None, allowed_attributes=None, **kwargs):
-
-    # Security map dictionary
-    required = {}
-
-    # Get the permission; mainly to correctly handle CheckerPublic.
-    permission = viewmeta._handle_permission(_context, permission)
-
-    # The class must be specified.
-    if not class_:
-        raise ConfigurationError("Must specify a class.")
-
-    if not zope.interface.interfaces.IInterface.providedBy(provides):
-        raise ConfigurationError("Provides interface provide IInterface.")
-
-    ifaces = list(zope.interface.Declaration(provides).flattened())
-    if interfaces.IPagelet not in ifaces:
-        raise ConfigurationError("Provides interface must inherit IPagelet.")
-
-    # Build a new class that we can use different permission settings if we
-    # use the class more then once.
-    cdict = {}
-    cdict['__name__'] = name
-    cdict.update(kwargs)
-    new_class = type(class_.__name__, (class_, browser.BrowserPagelet), cdict)
-
-    # Set up permission mapping for various accessible attributes
-    viewmeta._handle_allowed_interface(
-        _context, allowed_interface, permission, required)
-    viewmeta._handle_allowed_attributes(
-        _context, allowed_attributes, permission, required)
-    viewmeta._handle_allowed_attributes(
-        _context, kwargs.keys(), permission, required)
-    viewmeta._handle_allowed_attributes(
-        _context, ('__call__', 'browserDefault', 'update', 'render',
-                   'publishTraverse'), permission, required)
-
-    # Register the interfaces.
-    viewmeta._handle_for(_context, for_)
-
-    # provide the custom provides interface if not allready provided
-    if not provides.implementedBy(new_class):
-        zope.interface.classImplements(new_class, provides)
-
-    # Create the security checker for the new class
-    zope.security.checker.defineChecker(new_class,
-        zope.security.checker.Checker(required))
-
-    # register pagelet
-    _context.action(
-        discriminator = ('pagelet', for_, layer, name),
-        callable = zope.component.zcml.handler,
-        args = ('registerAdapter',
-                new_class, (for_, layer), provides, name, _context.info),)

Copied: z3c.pagelet/tags/1.2.0/src/z3c/pagelet/zcml.py (from rev 103299, z3c.pagelet/trunk/src/z3c/pagelet/zcml.py)
===================================================================
--- z3c.pagelet/tags/1.2.0/src/z3c/pagelet/zcml.py	                        (rev 0)
+++ z3c.pagelet/tags/1.2.0/src/z3c/pagelet/zcml.py	2009-08-27 16:34:19 UTC (rev 103307)
@@ -0,0 +1,136 @@
+##############################################################################
+#
+# Copyright (c) 2005 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+$Id$
+"""
+__docformat__ = "reStructuredText"
+
+import zope.interface
+import zope.component
+import zope.component.zcml
+import zope.schema
+import zope.configuration.fields
+import zope.security.checker
+import zope.security.zcml
+from zope.configuration.exceptions import ConfigurationError
+from zope.publisher.interfaces.browser import IDefaultBrowserLayer
+
+from zope.browserpage import metaconfigure as viewmeta
+
+from z3c.pagelet import interfaces
+from z3c.pagelet import browser
+
+
+class IPageletDirective(zope.component.zcml.IBasicViewInformation):
+    """A directive to register a new pagelet.
+
+    The pagelet directive also supports an undefined set of keyword arguments
+    that are set as attributes on the pagelet after creation.
+    """
+
+    name = zope.schema.TextLine(
+        title=u"The name of the pagelet.",
+        description=u"The name shows up in URLs/paths. For example 'foo'.",
+        required=True)
+
+    class_ = zope.configuration.fields.GlobalObject(
+        title=u"Class",
+        description=u"A class that provides attributes used by the pagelet.",
+        required=True,
+        )
+
+    permission = zope.security.zcml.Permission(
+        title=u"Permission",
+        description=u"The permission needed to use the pagelet.",
+        required=True
+        )
+
+    for_ = zope.configuration.fields.GlobalObject(
+        title=u"Context",
+        description=u"The content interface or class this pagelet is for.",
+        required=False
+        )
+
+    provides = zope.configuration.fields.GlobalInterface(
+        title=u"The interface this pagelets provides.",
+        description=u"""
+        A pagelet can provide an interface.  This would be used for
+        views that support other views.""",
+        required=False,
+        default=interfaces.IPagelet,
+        )
+
+
+# Arbitrary keys and values are allowed to be passed to the pagelet.
+IPageletDirective.setTaggedValue('keyword_arguments', True)
+
+
+# pagelet directive
+def pageletDirective(
+    _context, class_, name, permission, for_=zope.interface.Interface,
+    layer=IDefaultBrowserLayer, provides=interfaces.IPagelet,
+    allowed_interface=None, allowed_attributes=None, **kwargs):
+
+    # Security map dictionary
+    required = {}
+
+    # Get the permission; mainly to correctly handle CheckerPublic.
+    permission = viewmeta._handle_permission(_context, permission)
+
+    # The class must be specified.
+    if not class_:
+        raise ConfigurationError("Must specify a class.")
+
+    if not zope.interface.interfaces.IInterface.providedBy(provides):
+        raise ConfigurationError("Provides interface provide IInterface.")
+
+    ifaces = list(zope.interface.Declaration(provides).flattened())
+    if interfaces.IPagelet not in ifaces:
+        raise ConfigurationError("Provides interface must inherit IPagelet.")
+
+    # Build a new class that we can use different permission settings if we
+    # use the class more then once.
+    cdict = {}
+    cdict['__name__'] = name
+    cdict.update(kwargs)
+    new_class = type(class_.__name__, (class_, browser.BrowserPagelet), cdict)
+
+    # Set up permission mapping for various accessible attributes
+    viewmeta._handle_allowed_interface(
+        _context, allowed_interface, permission, required)
+    viewmeta._handle_allowed_attributes(
+        _context, allowed_attributes, permission, required)
+    viewmeta._handle_allowed_attributes(
+        _context, kwargs.keys(), permission, required)
+    viewmeta._handle_allowed_attributes(
+        _context, ('__call__', 'browserDefault', 'update', 'render',
+                   'publishTraverse'), permission, required)
+
+    # Register the interfaces.
+    viewmeta._handle_for(_context, for_)
+
+    # provide the custom provides interface if not allready provided
+    if not provides.implementedBy(new_class):
+        zope.interface.classImplements(new_class, provides)
+
+    # Create the security checker for the new class
+    zope.security.checker.defineChecker(new_class,
+        zope.security.checker.Checker(required))
+
+    # register pagelet
+    _context.action(
+        discriminator = ('pagelet', for_, layer, name),
+        callable = zope.component.zcml.handler,
+        args = ('registerAdapter',
+                new_class, (for_, layer), provides, name, _context.info),)



More information about the Checkins mailing list