[Checkins] SVN: z3ext.layout/tags/1.4.3/ tag for 1.4.3 egg
Nikolay Kim
fafhrd at datacom.kz
Wed May 21 15:46:40 EDT 2008
Log message for revision 86885:
tag for 1.4.3 egg
Changed:
A z3ext.layout/tags/1.4.3/
D z3ext.layout/tags/1.4.3/CHANGES.txt
A z3ext.layout/tags/1.4.3/CHANGES.txt
D z3ext.layout/tags/1.4.3/setup.py
A z3ext.layout/tags/1.4.3/setup.py
D z3ext.layout/tags/1.4.3/src/z3ext/layout/README.txt
A z3ext.layout/tags/1.4.3/src/z3ext/layout/README.txt
D z3ext.layout/tags/1.4.3/src/z3ext/layout/interfaces.py
A z3ext.layout/tags/1.4.3/src/z3ext/layout/interfaces.py
D z3ext.layout/tags/1.4.3/src/z3ext/layout/layout.py
A z3ext.layout/tags/1.4.3/src/z3ext/layout/layout.py
D z3ext.layout/tags/1.4.3/src/z3ext/layout/tests.py
A z3ext.layout/tags/1.4.3/src/z3ext/layout/tests.py
A z3ext.layout/tags/1.4.3/src/z3ext/layout/zcml.txt
-=-
Copied: z3ext.layout/tags/1.4.3 (from rev 86883, z3ext.layout/trunk)
Deleted: z3ext.layout/tags/1.4.3/CHANGES.txt
===================================================================
--- z3ext.layout/trunk/CHANGES.txt 2008-05-21 17:15:05 UTC (rev 86883)
+++ z3ext.layout/tags/1.4.3/CHANGES.txt 2008-05-21 19:46:39 UTC (rev 86885)
@@ -1,93 +0,0 @@
-=======
-CHANGES
-=======
-
-1.4.2 (2008-05-14)
-------------------
-
-- Remove unused interfaces
-
-- Tests updated
-
-
-1.4.1 (2008-04-23)
-------------------
-
-- Use newer version of z3ext.autoinclude
-
-
-1.4 (2008-03-21)
-----------------
-
-- Added z3ext:pagelet directive
-
-- Code cleanup
-
-- Moved to svn.zope.org
-
-
-1.3.2 (2008-03-06)
-------------------
-
-- Removed context layouts
-
-
-1.3.1 (2008-02-21)
-------------------
-
-- Code cleanup
-
-- Remove code related to zope.formlib
-
-
-1.3.0 (2008-02-20)
-------------------
-
-- Removed code related to z3c.form
-
-
-1.2.1 (2008-02-18)
-------------------
-
-- Added 'redirect' method to IBrowserPagelet, this is usefull
- when we need redirect during 'update' method and we don't
- need render pagelet at all.
-
-- Added adapter to IPagelet for (context, request),
- this adapter gets browser:defaultView for context and if it IPagelet return it
-
-
-1.2.0 (2008-02-13)
-------------------
-
-- Remove all code related to persistent templates
-
-
-1.1.2 (2008-02-12)
-------------------
-
-- Added 'title' and 'description' fields layout directive
-
-- check ILayoutTemplateTAL for ISite
-
-
-1.1.0 (2008-02-08)
-------------------
-
-- Added compatibility with z3c.template layouts
-
-- Added ILayoutTemplateTAL interface, other packages
- can define adapter to this interface and change layout template
- TAL program (layout customization)
-
-
-1.0.1 (2008-02-02)
-------------------
-
-- Added required dependencies
-
-
-1.0.0 (2008-01-15)
-------------------
-
-- Initial release
Copied: z3ext.layout/tags/1.4.3/CHANGES.txt (from rev 86884, z3ext.layout/trunk/CHANGES.txt)
===================================================================
--- z3ext.layout/tags/1.4.3/CHANGES.txt (rev 0)
+++ z3ext.layout/tags/1.4.3/CHANGES.txt 2008-05-21 19:46:39 UTC (rev 86885)
@@ -0,0 +1,99 @@
+=======
+CHANGES
+=======
+
+1.4.3 (2008-05-22)
+------------------
+
+- Added LayoutNotFound exception
+
+
+1.4.2 (2008-05-14)
+------------------
+
+- Remove unused interfaces
+
+- Tests updated
+
+
+1.4.1 (2008-04-23)
+------------------
+
+- Use newer version of z3ext.autoinclude
+
+
+1.4 (2008-03-21)
+----------------
+
+- Added z3ext:pagelet directive
+
+- Code cleanup
+
+- Moved to svn.zope.org
+
+
+1.3.2 (2008-03-06)
+------------------
+
+- Removed context layouts
+
+
+1.3.1 (2008-02-21)
+------------------
+
+- Code cleanup
+
+- Remove code related to zope.formlib
+
+
+1.3.0 (2008-02-20)
+------------------
+
+- Removed code related to z3c.form
+
+
+1.2.1 (2008-02-18)
+------------------
+
+- Added 'redirect' method to IBrowserPagelet, this is usefull
+ when we need redirect during 'update' method and we don't
+ need render pagelet at all.
+
+- Added adapter to IPagelet for (context, request),
+ this adapter gets browser:defaultView for context and if it IPagelet return it
+
+
+1.2.0 (2008-02-13)
+------------------
+
+- Remove all code related to persistent templates
+
+
+1.1.2 (2008-02-12)
+------------------
+
+- Added 'title' and 'description' fields layout directive
+
+- check ILayoutTemplateTAL for ISite
+
+
+1.1.0 (2008-02-08)
+------------------
+
+- Added compatibility with z3c.template layouts
+
+- Added ILayoutTemplateTAL interface, other packages
+ can define adapter to this interface and change layout template
+ TAL program (layout customization)
+
+
+1.0.1 (2008-02-02)
+------------------
+
+- Added required dependencies
+
+
+1.0.0 (2008-01-15)
+------------------
+
+- Initial release
Deleted: z3ext.layout/tags/1.4.3/setup.py
===================================================================
--- z3ext.layout/trunk/setup.py 2008-05-21 17:15:05 UTC (rev 86883)
+++ z3ext.layout/tags/1.4.3/setup.py 2008-05-21 19:46:39 UTC (rev 86885)
@@ -1,76 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2007 Zope Corporation 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 for z3ext.layout package
-
-$Id$
-"""
-import sys, os
-from setuptools import setup, find_packages
-
-def read(*rnames):
- return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
-
-version='1.4.3dev'
-
-
-setup(name='z3ext.layout',
- version=version,
- description="A package implementing advanced Page Template patterns.",
- long_description=(
- 'Detailed Documentation\n' +
- '======================\n'
- + '\n\n' +
- read('src', 'z3ext', 'layout', 'README.txt')
- + '\n\n' +
- read('CHANGES.txt')
- ),
- 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'],
- author='Nikolay Kim',
- author_email='fafhrd91 at gmail.com',
- url='http://z3ext.net/',
- license='ZPL 2.1',
- packages=find_packages('src'),
- package_dir = {'':'src'},
- namespace_packages=['z3ext'],
- install_requires = ['setuptools',
- 'zope.event',
- 'zope.schema',
- 'zope.component',
- 'zope.interface',
- 'zope.security',
- 'zope.publisher',
- 'zope.configuration',
- 'zope.pagetemplate',
- 'zope.app.component',
- 'zope.app.publisher',
- 'zope.app.pagetemplate',
- 'z3c.autoinclude>=0.2',
- 'z3ext.statusmessage',
- ],
- extras_require = dict(test=['zope.app.container',
- 'zope.app.testing',
- 'zope.testing',
- ]),
- include_package_data = True,
- zip_safe = False
- )
Copied: z3ext.layout/tags/1.4.3/setup.py (from rev 86884, z3ext.layout/trunk/setup.py)
===================================================================
--- z3ext.layout/tags/1.4.3/setup.py (rev 0)
+++ z3ext.layout/tags/1.4.3/setup.py 2008-05-21 19:46:39 UTC (rev 86885)
@@ -0,0 +1,75 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Corporation 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 for z3ext.layout package
+
+$Id$
+"""
+import sys, os
+from setuptools import setup, find_packages
+
+def read(*rnames):
+ return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
+
+version='1.4.3'
+
+
+setup(name='z3ext.layout',
+ version=version,
+ description="A package implementing advanced Page Template patterns.",
+ long_description=(
+ 'Detailed Documentation\n' +
+ '======================\n'
+ + '\n\n' +
+ read('src', 'z3ext', 'layout', 'README.txt')
+ + '\n\n' +
+ read('CHANGES.txt')
+ ),
+ 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'],
+ author='Nikolay Kim',
+ author_email='fafhrd91 at gmail.com',
+ url='http://z3ext.net/',
+ license='ZPL 2.1',
+ packages=find_packages('src'),
+ package_dir = {'':'src'},
+ namespace_packages=['z3ext'],
+ install_requires = ['setuptools',
+ 'zope.event',
+ 'zope.schema',
+ 'zope.component',
+ 'zope.interface',
+ 'zope.security',
+ 'zope.publisher',
+ 'zope.configuration',
+ 'zope.pagetemplate',
+ 'zope.app.component',
+ 'zope.app.publisher',
+ 'zope.app.pagetemplate',
+ 'z3c.autoinclude',
+ ],
+ extras_require = dict(test=['zope.app.container',
+ 'zope.app.testing',
+ 'zope.testing',
+ ]),
+ include_package_data = True,
+ zip_safe = False
+ )
Deleted: z3ext.layout/tags/1.4.3/src/z3ext/layout/README.txt
===================================================================
--- z3ext.layout/trunk/src/z3ext/layout/README.txt 2008-05-21 17:15:05 UTC (rev 86883)
+++ z3ext.layout/tags/1.4.3/src/z3ext/layout/README.txt 2008-05-21 19:46:39 UTC (rev 86885)
@@ -1,394 +0,0 @@
-================
-Template layouts
-================
-
-Layouts is different way of building skin templates without METAL.
-
-We need load zcml file
-
- >>> import z3ext.layout
- >>> from zope.configuration import xmlconfig
- >>> context = xmlconfig.file('meta.zcml', z3ext.layout)
-
- >>> import os, tempfile
- >>> from zope import interface, component
- >>> from z3ext.layout import tests, interfaces
- >>> from z3ext.layout.pagelet import BrowserPagelet
-
-Let's define main layout for our skin, it like 'page' macros from basicskin or
-rotterdam. It will contains <html>, <head> and <body> tags.
-It's like main_template in CMF or 'page' macro in basicskin/rotterdam
-
- >>> temp_dir = tempfile.mkdtemp()
- >>> layoutportal = os.path.join(temp_dir, 'layoutportal.pt')
- >>> open(layoutportal, 'w').write('''<html>
- ... <head><title>My portal</title></head>
- ... <body><div id="portal" tal:content="structure view/render">
- ... </div>
- ... </body>
- ... </html>''')
-
-Let's define 'portal' layout
-
- >>> context = xmlconfig.string("""
- ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext">
- ... <z3ext:layout
- ... name="portal"
- ... for="zope.app.component.interfaces.ISite"
- ... template="%s" />
- ... </configure>"""%layoutportal, context)
-
-Here another layout.
-
- >>> layoutworkspace = os.path.join(temp_dir, 'layoutworkspace.pt')
- >>> open(layoutworkspace, 'w').write('''
- ... <div id="workspace" tal:content="structure view/render"></div>''')
-
- >>> context = xmlconfig.string("""
- ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext">
- ... <z3ext:layout
- ... name="workspace"
- ... layout="portal"
- ... for="zope.app.component.interfaces.ISite"
- ... template="%s" />
- ... </configure>"""%layoutworkspace, context)
-
-You should notice that we used layout="portal" it indicates that
-'workspace' layout uses 'portal' layout as parent. so 'workspace' will be rendered
-inside 'portal' layout
-
-Now we need very simple view that uses BrowserPagelet
-
- >>> class IMyView(interface.Interface):
- ... pass
-
- >>> class MyView(BrowserPagelet):
- ... interface.implements(IMyView)
- ...
- ... def render(self):
- ... return self.context.__name__
-
- >>> from zope.publisher.browser import TestRequest
- >>> request = TestRequest()
- >>> view = MyView(root, request)
-
-It return context __name__
-
- >>> view.__call__()
- 'root'
-
-By default BrowserPagelet uses layout without name, Let's create one, it will
-use 'workspace' layout as parent.
-
- >>> layoutcontent = os.path.join(temp_dir, 'layoutcontent.pt')
- >>> open(layoutcontent, 'w').write('''
- ... <div id="content" tal:content="structure view/render"></div>''')
-
- >>> context = xmlconfig.string("""
- ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext">
- ... <z3ext:layout
- ... layout="workspace"
- ... for="zope.app.component.interfaces.ISite"
- ... template="%s" />
- ... </configure>"""%layoutcontent, context)
-
- >>> print view()
- <html>
- <head><title>My portal</title></head>
- <body><div id="portal">
- <div id="workspace">
- <div id="content">root</div>
- </div>
- </div>
- </body>
- </html>
- <BLANKLINE>
-
-All 3 our layout rendered. view rendered inside nameless layout then in
--> 'workspace' layout -> 'portal' layout
-
-Now let's create several more content objects
-
- >>> folder1 = tests.Folder()
- >>> root['folder1'] = folder1
-
- >>> print MyView(folder1, request)()
- <html>
- <head><title>My portal</title></head>
- <body><div id="portal">
- <div id="workspace">
- <div id="content">folder1</div>
- </div>
- </div>
- </body>
- </html>
- <BLANKLINE>
-
-And another one.
-
- >>> folder1_1 = tests.Folder()
- >>> root['folder1']['folder1_1'] = folder1_1
-
- >>> folder1_1_1 = tests.Folder()
- >>> root['folder1']['folder1_1']['folder1_1_1'] = folder1_1_1
-
- >>> print MyView(folder1_1_1, request)()
- <html>
- <head><title>My portal</title></head>
- <body><div id="portal">
- <div id="workspace">
- <div id="content">folder1_1_1</div>
- </div>
- </div>
- </body>
- </html>
- <BLANKLINE>
-
-This is all quite easy. Let's use more complex example. For example
-later other developers decide change how portal looks for folder1 object
-they want that all folder1 and all it's childs(folder1_1, folder1_1_1) have
-same look.
-
-Let's add '<table>' with couple columns
-
- >>> layoutcolumns = os.path.join(temp_dir, 'layoutcolumns.pt')
- >>> open(layoutcolumns, 'w').write('''
- ... <table id="columns">
- ... <tr>
- ... <td id="column1">Column1</td>
- ... <td id="column2" tal:content="structure view/render"></td>
- ... <td id="column3">Column3</td>
- ... </tr>
- ... </table>''')
-
-We register new layout for different interafce
-
- >>> context = xmlconfig.string("""
- ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext">
- ... <z3ext:layout
- ... name="workspace"
- ... layout="portal"
- ... for="z3ext.layout.tests.IFolder1"
- ... template="%s" />
- ... </configure>"""%layoutcolumns, context)
-
- >>> interface.directlyProvides(folder1, tests.IFolder1)
-
- >>> print MyView(folder1, request)()
- <html>
- <head><title>My portal</title></head>
- <body><div id="portal">
- <table id="columns">
- <tr>
- <td id="column1">Column1</td>
- <td id="column2">
- <div id="content">folder1</div>
- </td>
- <td id="column3">Column3</td>
- </tr>
- </table>
- </div>
- </body>
- </html>
- <BLANKLINE>
-
-folder1 uses new 'workspace' layout, but what about other folders
-
- >>> print MyView(folder1_1, request)()
- <html>
- <head><title>My portal</title></head>
- <body><div id="portal">
- <table id="columns">
- <tr>
- <td id="column1">Column1</td>
- <td id="column2">
- <div id="content">folder1_1</div>
- </td>
- <td id="column3">Column3</td>
- </tr>
- </table>
- </div>
- </body>
- </html>
- <BLANKLINE>
-
- >>> print MyView(folder1_1_1, request)()
- <html>
- <head><title>My portal</title></head>
- <body><div id="portal">
- <table id="columns">
- <tr>
- <td id="column1">Column1</td>
- <td id="column2">
- <div id="content">folder1_1_1</div>
- </td>
- <td id="column3">Column3</td>
- </tr>
- </table>
- </div>
- </body>
- </html>
- <BLANKLINE>
-
-Now we also change how folder1_1 looks, we can replace nameless layout.
-Also we can use nameless layout as parent with layout="."
-
- >>> layoutcontent1_1 = os.path.join(temp_dir, 'layoutcontent1_1.pt')
- >>> open(layoutcontent1_1, 'w').write('''
- ... <div id="content1_1">
- ... <h1>Folder1_1</h1>
- ... <div tal:content="structure view/render"></div>
- ... </div>''')
-
- >>> context = xmlconfig.string("""
- ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext">
- ... <z3ext:layout
- ... layout="."
- ... for="z3ext.layout.tests.IFolder1_1"
- ... template="%s" />
- ... </configure>"""%layoutcontent1_1, context)
-
- >>> interface.directlyProvides(folder1_1, tests.IFolder1_1)
-
- >>> print MyView(folder1_1, request)()
- <html>
- <head><title>My portal</title></head>
- <body><div id="portal">
- <table id="columns">
- <tr>
- <td id="column1">Column1</td>
- <td id="column2">
- <div id="content">
- <div id="content1_1">
- <h1>Folder1_1</h1>
- <div>folder1_1</div>
- </div>
- </div>
- </td>
- <td id="column3">Column3</td>
- </tr>
- </table>
- </div>
- </body>
- </html>
- <BLANKLINE>
-
-It still uses nameless layout that we defined for 'root'.
-
-And same for folder1_1_1
-
- >>> layoutcontent1_1_1 = os.path.join(temp_dir, 'layoutcontent1_1_1.pt')
- >>> open(layoutcontent1_1_1, 'w').write('''
- ... <div id="content1_1_1">
- ... <h1>Folder1_1_1</h1>
- ... <div tal:content="structure view/render"></div>
- ... </div>''')
-
- >>> context = xmlconfig.string("""
- ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext">
- ... <z3ext:layout
- ... layout="."
- ... for="z3ext.layout.tests.IFolder1_1_1"
- ... template="%s" />
- ... </configure>"""%layoutcontent1_1_1, context)
-
- >>> interface.directlyProvides(folder1_1_1, tests.IFolder1_1_1)
-
- >>> print MyView(folder1_1_1, request)()
- <html>
- <head><title>My portal</title></head>
- <body><div id="portal">
- <table id="columns">
- <tr>
- <td id="column1">Column1</td>
- <td id="column2">
- <div id="content">
- <div id="content1_1">
- <h1>Folder1_1</h1>
- <div>
- <div id="content1_1_1">
- <h1>Folder1_1_1</h1>
- <div>folder1_1_1</div>
- </div>
- </div>
- </div>
- </div>
- </td>
- <td id="column3">Column3</td>
- </tr>
- </table>
- </div>
- </body>
- </html>
- <BLANKLINE>
-
-Just tests
-
-We should provide template
-
- >>> context = xmlconfig.string("""
- ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext">
- ... <z3ext:layout
- ... layout="."
- ... template="unknown.pt" />
- ... </configure>""", context)
- Traceback (most recent call last):
- ...
- ZopeXMLConfigurationError: ...
- ... ConfigurationError: ('No such file', ...unknown.pt')
-
-We can register layout for context or for view
-
- >>> context = xmlconfig.string("""
- ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext">
- ... <z3ext:layout
- ... layout="."
- ... template="%s" />
- ... </configure>"""%layoutcontent1_1_1, context)
- Traceback (most recent call last):
- ...
- ZopeXMLConfigurationError: ...
- ... ConfigurationError: FOR or VIEW are required.
-
-We can register layout for view
-
- >>> context = xmlconfig.string("""
- ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext">
- ... <z3ext:layout
- ... layout="."
- ... view="z3ext.layout.tests.IFolder1_1_1"
- ... template="%s" />
- ... </configure>"""%layoutcontent1_1_1, context)
-
- >>> context = xmlconfig.string("""
- ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext">
- ... <z3ext:layout
- ... name="layout1"
- ... layout="."
- ... view="z3ext.layout.tests.IFolder1_1_1"
- ... template="%s" />
- ... </configure>"""%layoutcontent1_1_1, context)
-
-We can add custom marker interface for layout
-
- >>> context = xmlconfig.string("""
- ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext">
- ... <z3ext:layout
- ... name="layout2"
- ... layout="."
- ... view="z3ext.layout.tests.IFolder1_1_1"
- ... provides="z3ext.layout.tests.IFolder1"
- ... template="%s" />
- ... </configure>"""%layoutcontent1_1_1, context)
-
-We can use custom layout class
-
- >>> context = xmlconfig.string("""
- ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext">
- ... <z3ext:layout
- ... name="layout3"
- ... layout="."
- ... view="z3ext.layout.tests.IFolder1_1_1"
- ... class="z3ext.layout.tests.MyLayout"
- ... template="%s" />
- ... </configure>"""%layoutcontent1_1_1, context)
Copied: z3ext.layout/tags/1.4.3/src/z3ext/layout/README.txt (from rev 86884, z3ext.layout/trunk/src/z3ext/layout/README.txt)
===================================================================
--- z3ext.layout/tags/1.4.3/src/z3ext/layout/README.txt (rev 0)
+++ z3ext.layout/tags/1.4.3/src/z3ext/layout/README.txt 2008-05-21 19:46:39 UTC (rev 86885)
@@ -0,0 +1,318 @@
+================
+Template layouts
+================
+
+Layouts is different way of building skin templates without METAL.
+
+We need load zcml file
+
+ >>> import z3ext.layout
+ >>> from zope.configuration import xmlconfig
+ >>> context = xmlconfig.file('meta.zcml', z3ext.layout)
+
+ >>> import os, tempfile
+ >>> from zope import interface, component
+ >>> from z3ext.layout import tests, interfaces
+ >>> from z3ext.layout.pagelet import BrowserPagelet
+
+Let's define main layout for our skin, it like 'page' macros from basicskin or
+rotterdam. It will contains <html>, <head> and <body> tags.
+It's like main_template in CMF or 'page' macro in basicskin/rotterdam
+
+ >>> temp_dir = tempfile.mkdtemp()
+ >>> layoutportal = os.path.join(temp_dir, 'layoutportal.pt')
+ >>> open(layoutportal, 'w').write(
+ ... '''<html>
+ ... <body>
+ ... <div id="portal" tal:content="structure view/render">
+ ... </div>
+ ... </body>
+ ... </html>''')
+
+Let's define 'portal' layout
+
+ >>> context = xmlconfig.string("""
+ ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext">
+ ... <z3ext:layout
+ ... name="portal"
+ ... for="zope.app.component.interfaces.ISite"
+ ... template="%s" />
+ ... </configure>"""%layoutportal, context)
+
+Here another layout.
+
+ >>> layoutworkspace = os.path.join(temp_dir, 'layoutworkspace.pt')
+ >>> open(layoutworkspace, 'w').write('''
+ ... <div id="workspace" tal:content="structure view/render"></div>''')
+
+ >>> context = xmlconfig.string("""
+ ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext">
+ ... <z3ext:layout
+ ... name="workspace"
+ ... layout="portal"
+ ... for="zope.app.component.interfaces.ISite"
+ ... template="%s" />
+ ... </configure>"""%layoutworkspace, context)
+
+You should notice that we used layout="portal" it indicates that
+'workspace' layout uses 'portal' layout as parent. so 'workspace' will be rendered
+inside 'portal' layout
+
+Now we need very simple view that uses BrowserPagelet
+
+ >>> class IMyView(interface.Interface):
+ ... pass
+
+ >>> class MyView(BrowserPagelet):
+ ... interface.implements(IMyView)
+ ...
+ ... def render(self):
+ ... return self.context.__name__
+
+ >>> from zope.publisher.browser import TestRequest
+ >>> request = TestRequest()
+ >>> view = MyView(root, request)
+
+It returns context __name__
+
+ >>> view.__call__()
+ 'root'
+
+By default BrowserPagelet uses layout without name, Let's create one, it will
+use 'workspace' layout as parent.
+
+ >>> layoutcontent = os.path.join(temp_dir, 'layoutcontent.pt')
+ >>> open(layoutcontent, 'w').write('''
+ ... <div id="content" tal:content="structure view/render"></div>''')
+
+ >>> context = xmlconfig.string("""
+ ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext">
+ ... <z3ext:layout
+ ... layout="workspace"
+ ... for="zope.app.component.interfaces.ISite"
+ ... template="%s" />
+ ... </configure>"""%layoutcontent, context)
+
+ >>> print view()
+ <html>
+ <body>
+ <div id="portal">
+ <div id="workspace">
+ <div id="content">root</div>
+ </div>
+ </div>
+ </body>
+ </html>
+
+All 3 our layout rendered. view rendered inside nameless layout then in
+-> 'workspace' layout -> 'portal' layout
+
+Now let's create several more content objects
+
+ >>> folder1 = tests.Folder()
+ >>> root['folder1'] = folder1
+
+ >>> print MyView(folder1, request)()
+ <html>
+ <body>
+ <div id="portal">
+ <div id="workspace">
+ <div id="content">folder1</div>
+ </div>
+ </div>
+ </body>
+ </html>
+
+And another one.
+
+ >>> folder1_1 = tests.Folder()
+ >>> root['folder1']['folder1_1'] = folder1_1
+
+ >>> folder1_1_1 = tests.Folder()
+ >>> root['folder1']['folder1_1']['folder1_1_1'] = folder1_1_1
+
+ >>> print MyView(folder1_1_1, request)()
+ <html>
+ <body>
+ <div id="portal">
+ <div id="workspace">
+ <div id="content">folder1_1_1</div>
+ </div>
+ </div>
+ </body>
+ </html>
+
+This is all quite easy. Let's use more complex example. For example
+later other developers decide change how portal looks for folder1 object
+they want that all folder1 and all it's childs(folder1_1, folder1_1_1) have
+same look.
+
+Let's add '<table>' with couple columns
+
+ >>> layoutcolumns = os.path.join(temp_dir, 'layoutcolumns.pt')
+ >>> open(layoutcolumns, 'w').write('''
+ ... <table id="columns">
+ ... <tr>
+ ... <td id="column1">Column1</td>
+ ... <td id="column2" tal:content="structure view/render"></td>
+ ... <td id="column3">Column3</td>
+ ... </tr>
+ ... </table>''')
+
+We register new layout for different interafce
+
+ >>> context = xmlconfig.string("""
+ ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext">
+ ... <z3ext:layout
+ ... name="workspace"
+ ... layout="portal"
+ ... for="z3ext.layout.tests.IFolder1"
+ ... template="%s" />
+ ... </configure>"""%layoutcolumns, context)
+
+ >>> interface.directlyProvides(folder1, tests.IFolder1)
+
+ >>> print MyView(folder1, request)()
+ <html>
+ <body>
+ <div id="portal">
+ <table id="columns">
+ <tr>
+ <td id="column1">Column1</td>
+ <td id="column2">
+ <div id="content">folder1</div>
+ </td>
+ <td id="column3">Column3</td>
+ </tr>
+ </table>
+ </div>
+ </body>
+ </html>
+
+folder1 uses new 'workspace' layout, but what about other folders
+
+ >>> print MyView(folder1_1, request)()
+ <html>
+ <body>
+ <div id="portal">
+ <table id="columns">
+ <tr>
+ <td id="column1">Column1</td>
+ <td id="column2">
+ <div id="content">folder1_1</div>
+ </td>
+ <td id="column3">Column3</td>
+ </tr>
+ </table>
+ </div>
+ </body>
+ </html>
+
+
+ >>> print MyView(folder1_1_1, request)()
+ <html>
+ <body>
+ <div id="portal">
+ <table id="columns">
+ <tr>
+ <td id="column1">Column1</td>
+ <td id="column2">
+ <div id="content">folder1_1_1</div>
+ </td>
+ <td id="column3">Column3</td>
+ </tr>
+ </table>
+ </div>
+ </body>
+ </html>
+
+
+Now we also change how folder1_1 looks, we can replace nameless layout.
+Also we can use nameless layout as parent with layout="."
+
+ >>> layoutcontent1_1 = os.path.join(temp_dir, 'layoutcontent1_1.pt')
+ >>> open(layoutcontent1_1, 'w').write('''
+ ... <div id="content1_1">
+ ... <h1>Folder1_1</h1>
+ ... <div tal:content="structure view/render"></div>
+ ... </div>''')
+
+ >>> context = xmlconfig.string("""
+ ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext">
+ ... <z3ext:layout
+ ... layout="."
+ ... for="z3ext.layout.tests.IFolder1_1"
+ ... template="%s" />
+ ... </configure>"""%layoutcontent1_1, context)
+
+ >>> interface.directlyProvides(folder1_1, tests.IFolder1_1)
+
+ >>> print MyView(folder1_1, request)()
+ <html>
+ <body>
+ <div id="portal">
+ <table id="columns">
+ <tr>
+ <td id="column1">Column1</td>
+ <td id="column2">
+ <div id="content">
+ <div id="content1_1">
+ <h1>Folder1_1</h1>
+ <div>folder1_1</div>
+ </div>
+ </div>
+ </td>
+ <td id="column3">Column3</td>
+ </tr>
+ </table>
+ </div>
+ </body>
+ </html>
+
+It still uses nameless layout that we defined for 'root'.
+
+And same for folder1_1_1
+
+ >>> layoutcontent1_1_1 = os.path.join(temp_dir, 'layoutcontent1_1_1.pt')
+ >>> open(layoutcontent1_1_1, 'w').write('''
+ ... <div id="content1_1_1">
+ ... <h1>Folder1_1_1</h1>
+ ... <div tal:content="structure view/render"></div>
+ ... </div>''')
+
+ >>> context = xmlconfig.string("""
+ ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext">
+ ... <z3ext:layout
+ ... layout="."
+ ... for="z3ext.layout.tests.IFolder1_1_1"
+ ... template="%s" />
+ ... </configure>"""%layoutcontent1_1_1, context)
+
+ >>> interface.directlyProvides(folder1_1_1, tests.IFolder1_1_1)
+
+ >>> print MyView(folder1_1_1, request)()
+ <html>
+ <body>
+ <div id="portal">
+ <table id="columns">
+ <tr>
+ <td id="column1">Column1</td>
+ <td id="column2">
+ <div id="content">
+ <div id="content1_1">
+ <h1>Folder1_1</h1>
+ <div>
+ <div id="content1_1_1">
+ <h1>Folder1_1_1</h1>
+ <div>folder1_1_1</div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </td>
+ <td id="column3">Column3</td>
+ </tr>
+ </table>
+ </div>
+ </body>
+ </html>
Deleted: z3ext.layout/tags/1.4.3/src/z3ext/layout/interfaces.py
===================================================================
--- z3ext.layout/trunk/src/z3ext/layout/interfaces.py 2008-05-21 17:15:05 UTC (rev 86883)
+++ z3ext.layout/tags/1.4.3/src/z3ext/layout/interfaces.py 2008-05-21 19:46:39 UTC (rev 86885)
@@ -1,72 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2007 Zope Corporation 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.
-#
-##############################################################################
-""" z3ext.layout interfaces
-
-$Id$
-"""
-from zope import interface
-from zope.publisher.interfaces.browser import IBrowserPage
-
-
-class IPagelet(IBrowserPage):
- """ pagelet """
-
- isRedirected = interface.Attribute('is redirected')
-
- def redirect(url=''):
- """Redirect URL, if `update` method needs redirect,
- it should call `redirect` method, __call__ method should
- check isRendered before render or layout."""
-
- def update():
- """Update the pagelet data."""
-
- def render():
- """Render the pagelet content w/o o-wrap."""
-
-
-class ILayout(IBrowserPage):
- """ layout """
-
- title = interface.Attribute('Layout title')
-
- description = interface.Attribute('Layout description')
-
- template = interface.Attribute('Layout template')
-
- def update():
- """Update the layout data """
-
- def render():
- """Render the layout """
-
-
-class ILayoutTemplateFile(interface.Interface):
- """ layout template file """
-
-
-class ILayoutCreatedEvent(interface.Interface):
- """ notification about new layout """
-
- name = interface.Attribute('Name')
-
- view = interface.Attribute('View')
-
- context = interface.Attribute('Context')
-
- layer = interface.Attribute('Layer')
-
- layoutclass = interface.Attribute('Generated class for layout')
-
- keywords = interface.Attribute('Keywords')
Copied: z3ext.layout/tags/1.4.3/src/z3ext/layout/interfaces.py (from rev 86884, z3ext.layout/trunk/src/z3ext/layout/interfaces.py)
===================================================================
--- z3ext.layout/tags/1.4.3/src/z3ext/layout/interfaces.py (rev 0)
+++ z3ext.layout/tags/1.4.3/src/z3ext/layout/interfaces.py 2008-05-21 19:46:39 UTC (rev 86885)
@@ -0,0 +1,76 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Corporation 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.
+#
+##############################################################################
+""" z3ext.layout interfaces
+
+$Id$
+"""
+from zope import interface
+from zope.publisher.interfaces.browser import IBrowserPage
+
+
+class LayoutNotFound(LookupError):
+ """ Layout not found exception """
+
+
+class IPagelet(IBrowserPage):
+ """ pagelet """
+
+ isRedirected = interface.Attribute('is redirected')
+
+ def redirect(url=''):
+ """Redirect URL, if `update` method needs redirect,
+ it should call `redirect` method, __call__ method should
+ check isRendered before render or layout."""
+
+ def update():
+ """Update the pagelet data."""
+
+ def render():
+ """Render the pagelet content w/o o-wrap."""
+
+
+class ILayout(IBrowserPage):
+ """ layout """
+
+ title = interface.Attribute('Layout title')
+
+ description = interface.Attribute('Layout description')
+
+ template = interface.Attribute('Layout template')
+
+ def update():
+ """Update the layout data """
+
+ def render():
+ """Render the layout """
+
+
+class ILayoutTemplateFile(interface.Interface):
+ """ layout template file """
+
+
+class ILayoutCreatedEvent(interface.Interface):
+ """ notification about new layout """
+
+ name = interface.Attribute('Name')
+
+ view = interface.Attribute('View')
+
+ context = interface.Attribute('Context')
+
+ layer = interface.Attribute('Layer')
+
+ layoutclass = interface.Attribute('Generated class for layout')
+
+ keywords = interface.Attribute('Keywords')
Deleted: z3ext.layout/tags/1.4.3/src/z3ext/layout/layout.py
===================================================================
--- z3ext.layout/trunk/src/z3ext/layout/layout.py 2008-05-21 17:15:05 UTC (rev 86883)
+++ z3ext.layout/tags/1.4.3/src/z3ext/layout/layout.py 2008-05-21 19:46:39 UTC (rev 86885)
@@ -1,119 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2007 Zope Corporation 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$
-"""
-from zope import interface
-from zope.publisher import browser
-from zope.component import getMultiAdapter
-
-from zope.app.pagetemplate.engine import TrustedAppPT
-from zope.pagetemplate.pagetemplatefile import PageTemplateFile
-
-from z3ext.layout.pagelet import queryLayout
-from z3ext.layout.interfaces import ILayout, ILayoutTemplateFile
-
-
-class ViewMapper(object):
-
- def __init__(self, ob, request):
- self.ob = ob
- self.request = request
-
- def __getitem__(self, name):
- return getMultiAdapter((self.ob, self.request), name=name)
-
-
-class LayoutTemplateFile(TrustedAppPT, PageTemplateFile):
- interface.implements(ILayoutTemplateFile)
-
- expand = False
-
- def __init__(self, filename, _prefix=None, content_type=None):
- _prefix = self.get_path_from_prefix(_prefix)
- super(LayoutTemplateFile, self).__init__(filename, _prefix)
- if content_type is not None:
- self.content_type = content_type
-
- def pt_getContext(self, layout, **_kw):
- view = layout.view
-
- # instance is a View component
- namespace = super(LayoutTemplateFile, self).pt_getContext(**_kw)
- namespace['view'] = view
- namespace['request'] = layout.request
- namespace['context'] = view.context
- namespace['layout'] = layout
- namespace['layoutcontext'] = layout.context
- namespace['mainview'] = layout.mainview
- namespace['maincontext'] = layout.maincontext
- namespace['views'] = ViewMapper(view.context, layout.request)
- return namespace
-
- def __call__(self, layout, *args, **kw):
- namespace = self.pt_getContext(layout, args=args, options=kw)
- return self.pt_render(namespace)
-
-
-class Layout(browser.BrowserPage):
- interface.implements(ILayout)
-
- mainview = None
- maincontext = None
-
- def __init__(self, view, context, request):
- self.view = view
- self.context = context
- self.request = request
-
- self.__parent__ = view.context
-
- def update(self):
- pass
-
- def render(self):
- return self.template(self)
-
- def __call__(self, layout=None, view=None, *args, **kw):
- if view is None:
- view = self.view
- self.mainview = view
- self.maincontext = view.context
-
- layoutview = self.view
- if layout is not None:
- self.view = layout
-
- self.update()
-
- if self.layout is None:
- return self.render()
-
- if self.__name__ != self.layout:
- layout = queryLayout(view, self.request, name=self.layout)
- if layout is not None:
- return layout(layout=self, view=view, *args, **kw)
- else:
- if layoutview.context is not self.context.__parent__:
- context = self.context.__parent__
- else:
- context = getattr(self.context.__parent__, '__parent__')
-
- layout = queryLayout(self, self.request, context, name=self.layout)
- if layout is not None:
- return layout(view=view, *args, **kw)
-
- layout = queryLayout(self.context, self.request, name=self.layout)
- return layout(maincontext=maincontext, *args, **kw)
Copied: z3ext.layout/tags/1.4.3/src/z3ext/layout/layout.py (from rev 86884, z3ext.layout/trunk/src/z3ext/layout/layout.py)
===================================================================
--- z3ext.layout/tags/1.4.3/src/z3ext/layout/layout.py (rev 0)
+++ z3ext.layout/tags/1.4.3/src/z3ext/layout/layout.py 2008-05-21 19:46:39 UTC (rev 86885)
@@ -0,0 +1,122 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Corporation 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$
+"""
+from zope import interface
+from zope.publisher import browser
+from zope.component import getMultiAdapter
+
+from zope.app.pagetemplate.engine import TrustedAppPT
+from zope.pagetemplate.pagetemplatefile import PageTemplateFile
+
+from z3ext.layout.pagelet import queryLayout
+from z3ext.layout.interfaces import LayoutNotFound, ILayout, ILayoutTemplateFile
+
+
+class ViewMapper(object):
+
+ def __init__(self, ob, request):
+ self.ob = ob
+ self.request = request
+
+ def __getitem__(self, name):
+ return getMultiAdapter((self.ob, self.request), name=name)
+
+
+class LayoutTemplateFile(TrustedAppPT, PageTemplateFile):
+ interface.implements(ILayoutTemplateFile)
+
+ expand = False
+
+ def __init__(self, filename, _prefix=None, content_type=None):
+ _prefix = self.get_path_from_prefix(_prefix)
+ super(LayoutTemplateFile, self).__init__(filename, _prefix)
+ if content_type is not None:
+ self.content_type = content_type
+
+ def pt_getContext(self, layout, **_kw):
+ view = layout.view
+
+ # instance is a View component
+ namespace = super(LayoutTemplateFile, self).pt_getContext(**_kw)
+ namespace['view'] = view
+ namespace['request'] = layout.request
+ namespace['context'] = view.context
+ namespace['layout'] = layout
+ namespace['layoutcontext'] = layout.context
+ namespace['mainview'] = layout.mainview
+ namespace['maincontext'] = layout.maincontext
+ namespace['views'] = ViewMapper(view.context, layout.request)
+ return namespace
+
+ def __call__(self, layout, *args, **kw):
+ namespace = self.pt_getContext(layout, args=args, options=kw)
+ return self.pt_render(namespace)
+
+
+class Layout(browser.BrowserPage):
+ interface.implements(ILayout)
+
+ mainview = None
+ maincontext = None
+
+ def __init__(self, view, context, request):
+ self.view = view
+ self.context = context
+ self.request = request
+
+ self.__parent__ = view.context
+
+ def update(self):
+ pass
+
+ def render(self):
+ return self.template(self)
+
+ def __call__(self, layout=None, view=None, *args, **kw):
+ if view is None:
+ view = self.view
+ self.mainview = view
+ self.maincontext = view.context
+
+ layoutview = self.view
+ if layout is not None:
+ self.view = layout
+
+ self.update()
+
+ if self.layout is None:
+ return self.render()
+
+ if self.__name__ != self.layout:
+ layout = queryLayout(view, self.request, name=self.layout)
+ if layout is not None:
+ return layout(layout=self, view=view, *args, **kw)
+ else:
+ if layoutview.context is not self.context.__parent__:
+ context = self.context.__parent__
+ else:
+ context = getattr(self.context.__parent__, '__parent__')
+
+ layout = queryLayout(self, self.request, context, name=self.layout)
+ if layout is not None:
+ return layout(view=view, *args, **kw)
+
+ layout = queryLayout(self.view, self.context, self.request, name=self.layout)
+ if layout is not None:
+ return layout(*args, **kw)
+
+ raise LayoutNotFound(self.layout)
Deleted: z3ext.layout/tags/1.4.3/src/z3ext/layout/tests.py
===================================================================
--- z3ext.layout/trunk/src/z3ext/layout/tests.py 2008-05-21 17:15:05 UTC (rev 86883)
+++ z3ext.layout/tags/1.4.3/src/z3ext/layout/tests.py 2008-05-21 19:46:39 UTC (rev 86885)
@@ -1,71 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2008 Zope Corporation 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$
-"""
-import unittest, doctest
-from zope import interface, component
-from zope.testing.doctestunit import DocFileSuite
-from zope.app.testing import setup
-from zope.app.container.sample import SampleContainer
-
-from z3ext.layout import pagelet
-
-
-class IFolder1(interface.Interface):
- pass
-
-class IFolder1_1(interface.Interface):
- pass
-
-class IFolder1_1_1(interface.Interface):
- pass
-
-
-class Folder(SampleContainer):
- pass
-
-
-class MyLayout(object):
-
- title = u'My layout'
-
-
-def setUp(test):
- root = setup.placefulSetUp(site=True)
- root.__name__ = 'root'
- test.globs['root'] = root
- component.provideAdapter(pagelet.queryPagelet)
- setup.setUpTestAsModule(test, 'z3ext.layout.TESTS')
-
-
-def tearDown(test):
- setup.placefulTearDown()
- setup.tearDownTestAsModule(test)
-
-
-def test_suite():
- return unittest.TestSuite((
- doctest.DocFileSuite(
- 'README.txt',
- setUp=setUp, tearDown=tearDown,
- optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
- ),
- doctest.DocFileSuite(
- 'pagelet.txt',
- setUp=setUp, tearDown=tearDown,
- optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
- ),
- ))
Copied: z3ext.layout/tags/1.4.3/src/z3ext/layout/tests.py (from rev 86884, z3ext.layout/trunk/src/z3ext/layout/tests.py)
===================================================================
--- z3ext.layout/tags/1.4.3/src/z3ext/layout/tests.py (rev 0)
+++ z3ext.layout/tags/1.4.3/src/z3ext/layout/tests.py 2008-05-21 19:46:39 UTC (rev 86885)
@@ -0,0 +1,76 @@
+##############################################################################
+#
+# Copyright (c) 2008 Zope Corporation 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$
+"""
+import unittest, doctest
+from zope import interface, component
+from zope.testing.doctestunit import DocFileSuite
+from zope.app.testing import setup
+from zope.app.container.sample import SampleContainer
+
+from z3ext.layout import pagelet
+
+
+class IFolder1(interface.Interface):
+ pass
+
+class IFolder1_1(interface.Interface):
+ pass
+
+class IFolder1_1_1(interface.Interface):
+ pass
+
+
+class Folder(SampleContainer):
+ pass
+
+
+class MyLayout(object):
+
+ title = u'My layout'
+
+
+def setUp(test):
+ root = setup.placefulSetUp(site=True)
+ root.__name__ = 'root'
+ test.globs['root'] = root
+ component.provideAdapter(pagelet.queryPagelet)
+ setup.setUpTestAsModule(test, 'z3ext.layout.TESTS')
+
+
+def tearDown(test):
+ setup.placefulTearDown()
+ setup.tearDownTestAsModule(test)
+
+
+def test_suite():
+ return unittest.TestSuite((
+ doctest.DocFileSuite(
+ 'README.txt',
+ setUp=setUp, tearDown=tearDown,
+ optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
+ ),
+ doctest.DocFileSuite(
+ 'pagelet.txt',
+ setUp=setUp, tearDown=tearDown,
+ optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
+ ),
+ doctest.DocFileSuite(
+ 'zcml.txt',
+ setUp=setUp, tearDown=tearDown,
+ optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
+ ),
+ ))
Copied: z3ext.layout/tags/1.4.3/src/z3ext/layout/zcml.txt (from rev 86884, z3ext.layout/trunk/src/z3ext/layout/zcml.txt)
===================================================================
--- z3ext.layout/tags/1.4.3/src/z3ext/layout/zcml.txt (rev 0)
+++ z3ext.layout/tags/1.4.3/src/z3ext/layout/zcml.txt 2008-05-21 19:46:39 UTC (rev 86885)
@@ -0,0 +1,86 @@
+
+Just tests
+
+ >>> import tempfile, os.path
+ >>> import z3ext.layout
+ >>> from zope.configuration import xmlconfig
+ >>> context = xmlconfig.file('meta.zcml', z3ext.layout)
+
+ >>> temp_dir = tempfile.mkdtemp()
+ >>> layoutportal = os.path.join(temp_dir, 'layoutportal.pt')
+ >>> open(layoutportal, 'w').write(
+ ... '''<html>
+ ... <body>
+ ... <div id="portal" tal:content="structure view/render">
+ ... </div>
+ ... </body>
+ ... </html>''')
+
+We should provide template
+
+ >>> context = xmlconfig.string("""
+ ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext">
+ ... <z3ext:layout
+ ... layout="."
+ ... template="unknown.pt" />
+ ... </configure>""", context)
+ Traceback (most recent call last):
+ ...
+ ZopeXMLConfigurationError: ...
+ ... ConfigurationError: ('No such file', ...unknown.pt')
+
+We can register layout for context or for view
+
+ >>> context = xmlconfig.string("""
+ ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext">
+ ... <z3ext:layout
+ ... layout="."
+ ... template="%s" />
+ ... </configure>"""%layoutportal, context)
+ Traceback (most recent call last):
+ ...
+ ZopeXMLConfigurationError: ...
+ ... ConfigurationError: FOR or VIEW are required.
+
+We can register layout for view
+
+ >>> context = xmlconfig.string("""
+ ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext">
+ ... <z3ext:layout
+ ... layout="."
+ ... view="z3ext.layout.tests.IFolder1_1_1"
+ ... template="%s" />
+ ... </configure>"""%layoutportal, context)
+
+ >>> context = xmlconfig.string("""
+ ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext">
+ ... <z3ext:layout
+ ... name="layout1"
+ ... layout="."
+ ... view="z3ext.layout.tests.IFolder1_1_1"
+ ... template="%s" />
+ ... </configure>"""%layoutportal, context)
+
+We can add custom marker interface for layout
+
+ >>> context = xmlconfig.string("""
+ ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext">
+ ... <z3ext:layout
+ ... name="layout2"
+ ... layout="."
+ ... view="z3ext.layout.tests.IFolder1_1_1"
+ ... provides="z3ext.layout.tests.IFolder1"
+ ... template="%s" />
+ ... </configure>"""%layoutportal, context)
+
+We can use custom layout class
+
+ >>> context = xmlconfig.string("""
+ ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext">
+ ... <z3ext:layout
+ ... name="layout3"
+ ... layout="."
+ ... view="z3ext.layout.tests.IFolder1_1_1"
+ ... class="z3ext.layout.tests.MyLayout"
+ ... template="%s" />
+ ... </configure>"""%layoutportal, context)
More information about the Checkins
mailing list