[Checkins] SVN: z3ext.controlpanel/tags/1.2.5/ tag for release
Nikolay Kim
fafhrd at datacom.kz
Thu Aug 28 05:50:04 EDT 2008
Log message for revision 90539:
tag for release
Changed:
A z3ext.controlpanel/tags/1.2.5/
D z3ext.controlpanel/tags/1.2.5/CHANGES.txt
A z3ext.controlpanel/tags/1.2.5/CHANGES.txt
D z3ext.controlpanel/tags/1.2.5/setup.py
A z3ext.controlpanel/tags/1.2.5/setup.py
D z3ext.controlpanel/tags/1.2.5/src/z3ext/controlpanel/README.txt
A z3ext.controlpanel/tags/1.2.5/src/z3ext/controlpanel/README.txt
D z3ext.controlpanel/tags/1.2.5/src/z3ext/controlpanel/browser/tests/README.txt
A z3ext.controlpanel/tags/1.2.5/src/z3ext/controlpanel/browser/tests/README.txt
D z3ext.controlpanel/tags/1.2.5/src/z3ext/controlpanel/configlet.py
A z3ext.controlpanel/tags/1.2.5/src/z3ext/controlpanel/configlet.py
D z3ext.controlpanel/tags/1.2.5/src/z3ext/controlpanel/configure.zcml
A z3ext.controlpanel/tags/1.2.5/src/z3ext/controlpanel/configure.zcml
D z3ext.controlpanel/tags/1.2.5/src/z3ext/controlpanel/storage.py
A z3ext.controlpanel/tags/1.2.5/src/z3ext/controlpanel/storage.py
-=-
Copied: z3ext.controlpanel/tags/1.2.5 (from rev 90378, z3ext.controlpanel/trunk)
Deleted: z3ext.controlpanel/tags/1.2.5/CHANGES.txt
===================================================================
--- z3ext.controlpanel/trunk/CHANGES.txt 2008-08-27 04:31:17 UTC (rev 90378)
+++ z3ext.controlpanel/tags/1.2.5/CHANGES.txt 2008-08-28 09:50:03 UTC (rev 90539)
@@ -1,96 +0,0 @@
-=======
-CHANGES
-=======
-
-1.2.5 (2008-06-??)
-------------------
-
-- Remove wrong html tag for category view
-
-
-1.2.4 (2008-05-26)
-------------------
-
-- Fixed configlet subcategory + z3c.baseregistry bug
-
-
-1.2.3 (2008-05-14)
-------------------
-
-- Replace 'autoinclude' with 'includeDependendcies'
-
-- Tests updated
-
-
-1.2.2 (2008-04-08)
-------------------
-
-- Fix UI navigation
-
-
-1.2.1 (2008-03-28)
-------------------
-
-- Removed 'principals' configlet category
-
-
-1.2.0 (2008-03-21)
-------------------
-
-- Use z3ext.pagelet directive for browser views
-
-- Added i18n
-
-- Moved to svn.zope.org
-
-
-1.1.7 (2008-03-18)
-------------------
-
-- Added functional tests
-
-
-1.1.6 (2008-02-28)
-------------------
-
-- Use z3c.autoinclude
-
-
-1.1.5 (2008-02-22)
-------------------
-
-- Added buildout.cfg for testing
-
-- Added viewlet manager for configlet navigation
-
-
-1.1.4 (2008-02-20)
-------------------
-
-- Use z3ext.layoutform
-
-
-1.1.3 (2008-02-0?)
-------------------
-
-- Added 'UI' configuration category
-
-
-1.1.2 (2008-02-04)
-------------------
-
-- Fixed problem with generated class and persistence
-
-- Remove all <grant/> directives
-
-
-1.1.0 (2008-01-31)
-------------------
-
-- Use z3ext.layout for rendering
-
-
-1.0.0 (2007-26-07)
-------------------
-
-- Initial release
Copied: z3ext.controlpanel/tags/1.2.5/CHANGES.txt (from rev 90537, z3ext.controlpanel/trunk/CHANGES.txt)
===================================================================
--- z3ext.controlpanel/tags/1.2.5/CHANGES.txt (rev 0)
+++ z3ext.controlpanel/tags/1.2.5/CHANGES.txt 2008-08-28 09:50:03 UTC (rev 90539)
@@ -0,0 +1,100 @@
+=======
+CHANGES
+=======
+
+1.2.5 (2008-08-28)
+------------------
+
+- Remove wrong html tag for category view
+
+- Fix configlet storage name
+
+- Added copier for data storage
+
+
+1.2.4 (2008-05-26)
+------------------
+
+- Fixed configlet subcategory + z3c.baseregistry bug
+
+
+1.2.3 (2008-05-14)
+------------------
+
+- Replace 'autoinclude' with 'includeDependendcies'
+
+- Tests updated
+
+
+1.2.2 (2008-04-08)
+------------------
+
+- Fix UI navigation
+
+
+1.2.1 (2008-03-28)
+------------------
+
+- Removed 'principals' configlet category
+
+
+1.2.0 (2008-03-21)
+------------------
+
+- Use z3ext.pagelet directive for browser views
+
+- Added i18n
+
+- Moved to svn.zope.org
+
+
+1.1.7 (2008-03-18)
+------------------
+
+- Added functional tests
+
+
+1.1.6 (2008-02-28)
+------------------
+
+- Use z3c.autoinclude
+
+
+1.1.5 (2008-02-22)
+------------------
+
+- Added buildout.cfg for testing
+
+- Added viewlet manager for configlet navigation
+
+
+1.1.4 (2008-02-20)
+------------------
+
+- Use z3ext.layoutform
+
+
+1.1.3 (2008-02-0?)
+------------------
+
+- Added 'UI' configuration category
+
+
+1.1.2 (2008-02-04)
+------------------
+
+- Fixed problem with generated class and persistence
+
+- Remove all <grant/> directives
+
+
+1.1.0 (2008-01-31)
+------------------
+
+- Use z3ext.layout for rendering
+
+
+1.0.0 (2007-26-07)
+------------------
+
+- Initial release
Deleted: z3ext.controlpanel/tags/1.2.5/setup.py
===================================================================
--- z3ext.controlpanel/trunk/setup.py 2008-08-27 04:31:17 UTC (rev 90378)
+++ z3ext.controlpanel/tags/1.2.5/setup.py 2008-08-28 09:50:03 UTC (rev 90539)
@@ -1,87 +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.controlpanel 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.2.5dev'
-
-
-setup(name = 'z3ext.controlpanel',
- version = version,
- description = "Control Panel - userfriendly system control panel.",
- long_description = (
- 'Detailed Documentation\n' +
- '======================\n'
- + '\n\n' +
- read('src', 'z3ext', 'controlpanel', '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',
- 'ZODB3',
- 'zope.schema',
- 'zope.interface',
- 'zope.component',
- 'zope.annotation',
- 'zope.security',
- 'zope.location',
- 'zope.publisher',
- 'zope.i18nmessageid',
- 'zope.viewlet',
- 'zope.contentprovider',
- 'zope.cachedescriptors',
- 'zope.app.publisher',
- 'zope.app.component',
- 'zope.app.security',
- 'zope.configuration',
- 'z3c.traverser',
- 'z3c.autoinclude',
- 'z3ext.layout',
- 'z3ext.layoutform',
- ],
- extras_require = dict(test=['zope.securitypolicy',
- 'zope.app.security',
- 'zope.app.testing',
- 'zope.app.zcmlfiles',
- 'zope.traversing',
- 'zope.testing',
- 'zope.testbrowser',
- ]),
- include_package_data = True,
- zip_safe = False
- )
Copied: z3ext.controlpanel/tags/1.2.5/setup.py (from rev 90537, z3ext.controlpanel/trunk/setup.py)
===================================================================
--- z3ext.controlpanel/tags/1.2.5/setup.py (rev 0)
+++ z3ext.controlpanel/tags/1.2.5/setup.py 2008-08-28 09:50:03 UTC (rev 90539)
@@ -0,0 +1,88 @@
+##############################################################################
+#
+# 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.controlpanel 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.2.5'
+
+
+setup(name = 'z3ext.controlpanel',
+ version = version,
+ description = "Control Panel - userfriendly system control panel.",
+ long_description = (
+ 'Detailed Documentation\n' +
+ '======================\n'
+ + '\n\n' +
+ read('src', 'z3ext', 'controlpanel', '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',
+ 'ZODB3',
+ 'zope.schema',
+ 'zope.interface',
+ 'zope.component',
+ 'zope.annotation',
+ 'zope.security',
+ 'zope.location',
+ 'zope.publisher',
+ 'zope.i18nmessageid',
+ 'zope.viewlet',
+ 'zope.contentprovider',
+ 'zope.cachedescriptors',
+ 'zope.lifecycleevent',
+ 'zope.app.publisher',
+ 'zope.app.component',
+ 'zope.app.security',
+ 'zope.configuration',
+ 'z3c.traverser',
+ 'z3c.autoinclude',
+ 'z3ext.layout',
+ 'z3ext.layoutform',
+ ],
+ extras_require = dict(test=['zope.securitypolicy',
+ 'zope.app.security',
+ 'zope.app.testing',
+ 'zope.app.zcmlfiles',
+ 'zope.traversing',
+ 'zope.testing',
+ 'zope.testbrowser',
+ ]),
+ include_package_data = True,
+ zip_safe = False
+ )
Deleted: z3ext.controlpanel/tags/1.2.5/src/z3ext/controlpanel/README.txt
===================================================================
--- z3ext.controlpanel/trunk/src/z3ext/controlpanel/README.txt 2008-08-27 04:31:17 UTC (rev 90378)
+++ z3ext.controlpanel/tags/1.2.5/src/z3ext/controlpanel/README.txt 2008-08-28 09:50:03 UTC (rev 90539)
@@ -1,366 +0,0 @@
-=============
-Control Panel
-=============
-
-In many cases programm modules needs configuration and some common way
-of managing configuration. Control panel very similar with zope.app.preference,
-it stores all data in site annotation, in BTrees. so you can removeing
-and add any configlet without problem with zodb.
-
-We need load zcml configuration::
-
- >>> from zope.configuration import xmlconfig
- >>> import z3ext.controlpanel
- >>> context = xmlconfig.file('meta.zcml', z3ext.controlpanel)
-
- >>> from zope import interface, component, schema
- >>> from z3ext.controlpanel import interfaces
-
-We can register configlet with `z3ext:configlet` directive.
-
-Let's create simple configlet. First we need define configlet schema:
-
- >>> class ITestConfiglet1(interface.Interface):
- ...
- ... param1 = schema.TextLine(
- ... title = u'param1',
- ... default = u'default param1')
- ...
- ... param2 = schema.Int(
- ... title = u'param2',
- ... default = 10)
-
-Now configlet registration:
-
- >>> context = xmlconfig.string("""
- ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext"
- ... i18n_domain="zope">
- ... <z3ext:configlet
- ... name="configlet1"
- ... schema="z3ext.controlpanel.README.ITestConfiglet1"
- ... title="Test configlet1"
- ... description="Test configlet1 description" />
- ... </configure>""", context)
-
-That's all. now we can get configlet as utility.
-
-As named IConfiglet
-
- >>> cl = component.getUtility(interfaces.IConfiglet, name='configlet1')
- >>> cl.__name__ == 'configlet1'
- True
- >>> cl.__title__ == 'Test configlet1'
- True
- >>> cl.__description__ == 'Test configlet1 description'
- True
-
-As schema utility
-
- >>> cl1 = component.getUtility(ITestConfiglet1)
- >>> cl is cl1
- True
-
- >>> cl.__schema__
- <InterfaceClass z3ext.controlpanel.README.ITestConfiglet1>
-
-We can't change __schema__ at runtime
-
- >>> cl.__schema__ = ITestConfiglet1
- Traceback (most recent call last):
- ...
- AttributeError: Can't set __schema__
-
-
-IConfiglet
-----------
-
-Let's access configlet attributes:
-
- >>> cl.param1
- u'default param1'
-
- >>> cl.param2
- 10
-
-which is the default value, since we have not set it yet. We can now reassign
-the value:
-
- >>> cl.param1 = u'test'
- >>> cl.param1
- u'test'
-
-However, you cannot just enter any value, since it is validated before the
-assignment:
-
- >>> cl.param2 = 'str'
- Traceback (most recent call last):
- ...
- WrongType: ...
-
-You can delete attribute, default value would restored
-
- >>> del cl.param1
- >>> cl.param1
- u'default param1'
-
-You can set/remove any attributes to configlet, but this attributes won't
-be persistent.
-
- >>> cl.test = 1
- >>> cl.test
- 1
-
- >>> del cl.test
-
-Configlet is ILocation object so it can't be used in traversing
-
- >>> cl.__parent__
- <z3ext.controlpanel.root.RootConfiglet object at ...>
-
- >>> cl.__name__
- u'configlet1'
-
- >>> from zope.traversing.api import getPath
- >>> getPath(cl)
- u'/settings/configlet1'
-
-
-Configlet security
-------------------
-
-Read/Write access to configlet same as for <class> directive. By default
-all fields in IConfiglet interface and schema protected by 'z3ext.Configure'
-permission. We can define default permission in 'permission' attribute.
-We can use <require/> and <allow/> subdirectives inside <z3ext:configlet>
-directive.
-
- >>> class ITestConfiglet2(interface.Interface):
- ...
- ... param1 = schema.TextLine(
- ... title = u'param1',
- ... default = u'default param1')
- ...
- ... param2 = schema.Int(
- ... title = u'param2',
- ... default = 10)
- ...
- ... param3 = schema.TextLine(
- ... title = u'param3',
- ... default = u'default param3')
-
- >>> xmlconfig.string("""
- ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext"
- ... i18n_domain="zope">
- ... <include package="z3ext.controlpanel" file="meta.zcml" />
- ... <z3ext:configlet
- ... name="configlet2"
- ... schema="z3ext.controlpanel.README.ITestConfiglet2"
- ... title="Test configlet2"
- ... permission="zope.Public">
- ... <require />
- ... </z3ext:configlet>
- ... </configure>""")
- Traceback (most recent call last):
- ...
- ZopeXMLConfigurationError: ...Nothing required...
-
- >>> xmlconfig.string("""
- ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext"
- ... i18n_domain="zope">
- ... <include package="z3ext.controlpanel" file="meta.zcml" />
- ... <z3ext:configlet
- ... name="configlet2"
- ... schema="z3ext.controlpanel.README.ITestConfiglet2"
- ... title="Test configlet2"
- ... permission="zope.Public">
- ... <require attributes="param1" />
- ... </z3ext:configlet>
- ... </configure>""")
- Traceback (most recent call last):
- ...
- ZopeXMLConfigurationError: ...No permission specified...
-
- >>> context = xmlconfig.string("""
- ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext"
- ... i18n_domain="zope">
- ... <include package="z3ext.controlpanel" file="meta.zcml" />
- ... <z3ext:configlet
- ... name="configlet2"
- ... schema="z3ext.controlpanel.README.ITestConfiglet2"
- ... title="Test configlet2"
- ... permission="zope.Public">
- ... <require attributes="param1" permission="zope.Public" />
- ... <allow attributes="param2" />
- ... <require set_attributes="param3" permission="zope.Public" />
- ... </z3ext:configlet>
- ... </configure>""", context)
-
-
-Custom class implementation
----------------------------
-
-We can use custom configlet implementation
-
- >>> class TestConfiglet1(object):
- ... pass
-
- >>> context = xmlconfig.string("""
- ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext"
- ... i18n_domain="zope">
- ... <include package="z3ext.controlpanel" file="meta.zcml" />
- ... <z3ext:configlet
- ... name="configlet3"
- ... class="z3ext.controlpanel.README.TestConfiglet1"
- ... schema="z3ext.controlpanel.README.ITestConfiglet2"
- ... title="Test configlet3">
- ... </z3ext:configlet>
- ... </configure>""")
-
- >>> configlet = component.getUtility(interfaces.IConfiglet, 'configlet3')
- >>> isinstance(configlet, TestConfiglet1)
- True
-
-
-Configlet groups
-----------------
-
-The configlet would not be very powerful, if you could create a full
-settingss. So let's create a sub-configlet for settings:
-
- >>> len(configlet)
- 0
-
- >>> 'configlet' in configlet
- False
-
- >>> configlet.get('configlet') is None
- True
-
- >>> configlet['configlet']
- Traceback (most recent call last):
- ...
- KeyError: 'configlet'
-
- >>> context = xmlconfig.string("""
- ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext"
- ... i18n_domain="zope">
- ... <include package="z3ext.controlpanel" file="meta.zcml" />
- ... <z3ext:configlet
- ... name="configlet3.configlet"
- ... schema="z3ext.controlpanel.README.ITestConfiglet1"
- ... title="Test configlet4">
- ... </z3ext:configlet>
- ... </configure>""", context)
-
- >>> configlet['configlet'].__parent__ is configlet
- True
-
- >>> len(configlet)
- 1
-
- >>> 'configlet' in configlet
- True
-
- >>> configlet['configlet'].__id__
- u'configlet3.configlet'
-
- >>> configlet.items()
- [(u'configlet', <z3ext.controlpanel.configlettype.Configlet<configlet3.configlet> ...)]
-
- >>> configlet.values()
- [<z3ext.controlpanel.configlettype.Configlet<configlet3.configlet> ...>]
-
- >>> list(iter(configlet))
- [<z3ext.controlpanel.configlettype.Configlet<configlet3.configlet> ...>]
-
-
-Configlet availability
-----------------------
-
-We can check availability
-
- >>> def testConfiglet1(configlet):
- ... return True
-
- >>> def testConfiglet2(configlet):
- ... return False
-
- >>> c1 = configlet['configlet']
- >>> c1.isAvailable()
- True
-
- >>> c1.__tests__ = (testConfiglet2,)
- >>> c1.isAvailable()
- False
-
-Avialability automaticly checks in parent configlet
-
- >>> c1.__tests__ = (testConfiglet1,)
- >>> c1.isAvailable()
- True
-
- >>> configlet.__tests__ = (testConfiglet2,)
-
- >>> c1.isAvailable()
- False
-
- >>> c1.__tests__ = (testConfiglet1, testConfiglet2)
- >>> c1.isAvailable()
- False
-
- >>> configlet.remove('configlet')
- >>> len(configlet)
- 0
-
-We can add custom availability checks in z3ext:configlet directory
-
- >>> t = xmlconfig.string("""
- ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext"
- ... i18n_domain="zope">
- ... <include package="z3ext.controlpanel" file="meta.zcml" />
- ... <z3ext:configlet
- ... name="configlet"
- ... schema="z3ext.controlpanel.README.ITestConfiglet1"
- ... tests="z3ext.controlpanel.README.testConfiglet1"
- ... title="Test configlet">
- ... </z3ext:configlet>
- ... </configure>""")
-
-It should be callable
-
- >>> test = False
- >>> t = xmlconfig.string("""
- ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext"
- ... i18n_domain="zope">
- ... <include package="z3ext.controlpanel" file="meta.zcml" />
- ... <z3ext:configlet
- ... name="configlet"
- ... schema="z3ext.controlpanel.README.ITestConfiglet1"
- ... tests="z3ext.controlpanel.README.test"
- ... title="Test configlet">
- ... </z3ext:configlet>
- ... </configure>""")
- Traceback (most recent call last):
- ...
- ZopeXMLConfigurationError: ...
-
-
-Root configlet
---------------
-
-There is root configlet. You can access any other configlets from root configlet.
-This configlet has no name, so it's available as nameless IConfiglet utility:
-
- >>> from zope.app.component.hooks import getSite
-
- >>> root = component.getUtility(interfaces.IConfiglet)
- >>> root
- <z3ext.controlpanel.root.RootConfiglet object at ...>
-
-Root configlet parent is ISite object
-
- >>> root.__parent__ is getSite()
- True
-
- >>> ITestConfiglet1.providedBy(root['configlet1'])
- True
Copied: z3ext.controlpanel/tags/1.2.5/src/z3ext/controlpanel/README.txt (from rev 90537, z3ext.controlpanel/trunk/src/z3ext/controlpanel/README.txt)
===================================================================
--- z3ext.controlpanel/tags/1.2.5/src/z3ext/controlpanel/README.txt (rev 0)
+++ z3ext.controlpanel/tags/1.2.5/src/z3ext/controlpanel/README.txt 2008-08-28 09:50:03 UTC (rev 90539)
@@ -0,0 +1,366 @@
+=============
+Control Panel
+=============
+
+In many cases programm modules needs configuration and some common way
+of managing configuration. Control panel very similar with zope.app.preference,
+it stores all data in site annotation, in BTrees. so you can removeing
+and add any configlet without problem with zodb.
+
+We need load zcml configuration::
+
+ >>> from zope.configuration import xmlconfig
+ >>> import z3ext.controlpanel
+ >>> context = xmlconfig.file('meta.zcml', z3ext.controlpanel)
+
+ >>> from zope import interface, component, schema
+ >>> from z3ext.controlpanel import interfaces
+
+We can register configlet with `z3ext:configlet` directive.
+
+Let's create simple configlet. First we need define configlet schema:
+
+ >>> class ITestConfiglet1(interface.Interface):
+ ...
+ ... param1 = schema.TextLine(
+ ... title = u'param1',
+ ... default = u'default param1')
+ ...
+ ... param2 = schema.Int(
+ ... title = u'param2',
+ ... default = 10)
+
+Now configlet registration:
+
+ >>> context = xmlconfig.string("""
+ ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext"
+ ... i18n_domain="zope">
+ ... <z3ext:configlet
+ ... name="configlet1"
+ ... schema="z3ext.controlpanel.README.ITestConfiglet1"
+ ... title="Test configlet1"
+ ... description="Test configlet1 description" />
+ ... </configure>""", context)
+
+That's all. now we can get configlet as utility.
+
+As named IConfiglet
+
+ >>> cl = component.getUtility(interfaces.IConfiglet, name='configlet1')
+ >>> cl.__name__ == 'configlet1'
+ True
+ >>> cl.__title__ == 'Test configlet1'
+ True
+ >>> cl.__description__ == 'Test configlet1 description'
+ True
+
+As schema utility
+
+ >>> cl1 = component.getUtility(ITestConfiglet1)
+ >>> cl is cl1
+ True
+
+ >>> cl.__schema__
+ <InterfaceClass z3ext.controlpanel.README.ITestConfiglet1>
+
+We can't change __schema__ at runtime
+
+ >>> cl.__schema__ = ITestConfiglet1
+ Traceback (most recent call last):
+ ...
+ AttributeError: Can't set __schema__
+
+
+IConfiglet
+----------
+
+Let's access configlet attributes:
+
+ >>> cl.param1
+ u'default param1'
+
+ >>> cl.param2
+ 10
+
+which is the default value, since we have not set it yet. We can now reassign
+the value:
+
+ >>> cl.param1 = u'test'
+ >>> cl.param1
+ u'test'
+
+However, you cannot just enter any value, since it is validated before the
+assignment:
+
+ >>> cl.param2 = 'str'
+ Traceback (most recent call last):
+ ...
+ WrongType: ...
+
+You can delete attribute, default value would restored
+
+ >>> del cl.param1
+ >>> cl.param1
+ u'default param1'
+
+You can set/remove any attributes to configlet, but this attributes won't
+be persistent.
+
+ >>> cl.test = 1
+ >>> cl.test
+ 1
+
+ >>> del cl.test
+
+Configlet is ILocation object so it can't be used in traversing
+
+ >>> cl.__parent__
+ <z3ext.controlpanel.root.RootConfiglet object at ...>
+
+ >>> cl.__name__
+ u'configlet1'
+
+ >>> from zope.traversing.api import getPath
+ >>> getPath(cl)
+ u'/settings/configlet1'
+
+
+Configlet security
+------------------
+
+Read/Write access to configlet same as for <class> directive. By default
+all fields in IConfiglet interface and schema protected by 'z3ext.Configure'
+permission. We can define default permission in 'permission' attribute.
+We can use <require/> and <allow/> subdirectives inside <z3ext:configlet>
+directive.
+
+ >>> class ITestConfiglet2(interface.Interface):
+ ...
+ ... param1 = schema.TextLine(
+ ... title = u'param1',
+ ... default = u'default param1')
+ ...
+ ... param2 = schema.Int(
+ ... title = u'param2',
+ ... default = 10)
+ ...
+ ... param3 = schema.TextLine(
+ ... title = u'param3',
+ ... default = u'default param3')
+
+ >>> xmlconfig.string("""
+ ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext"
+ ... i18n_domain="zope">
+ ... <include package="z3ext.controlpanel" file="meta.zcml" />
+ ... <z3ext:configlet
+ ... name="configlet2"
+ ... schema="z3ext.controlpanel.README.ITestConfiglet2"
+ ... title="Test configlet2"
+ ... permission="zope.Public">
+ ... <require />
+ ... </z3ext:configlet>
+ ... </configure>""")
+ Traceback (most recent call last):
+ ...
+ ZopeXMLConfigurationError: ...Nothing required...
+
+ >>> xmlconfig.string("""
+ ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext"
+ ... i18n_domain="zope">
+ ... <include package="z3ext.controlpanel" file="meta.zcml" />
+ ... <z3ext:configlet
+ ... name="configlet2"
+ ... schema="z3ext.controlpanel.README.ITestConfiglet2"
+ ... title="Test configlet2"
+ ... permission="zope.Public">
+ ... <require attributes="param1" />
+ ... </z3ext:configlet>
+ ... </configure>""")
+ Traceback (most recent call last):
+ ...
+ ZopeXMLConfigurationError: ...No permission specified...
+
+ >>> context = xmlconfig.string("""
+ ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext"
+ ... i18n_domain="zope">
+ ... <include package="z3ext.controlpanel" file="meta.zcml" />
+ ... <z3ext:configlet
+ ... name="configlet2"
+ ... schema="z3ext.controlpanel.README.ITestConfiglet2"
+ ... title="Test configlet2"
+ ... permission="zope.Public">
+ ... <require attributes="param1" permission="zope.Public" />
+ ... <allow attributes="param2" />
+ ... <require set_attributes="param3" permission="zope.Public" />
+ ... </z3ext:configlet>
+ ... </configure>""", context)
+
+
+Custom class implementation
+---------------------------
+
+We can use custom configlet implementation
+
+ >>> class TestConfiglet1(object):
+ ... pass
+
+ >>> context = xmlconfig.string("""
+ ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext"
+ ... i18n_domain="zope">
+ ... <include package="z3ext.controlpanel" file="meta.zcml" />
+ ... <z3ext:configlet
+ ... name="configlet3"
+ ... class="z3ext.controlpanel.README.TestConfiglet1"
+ ... schema="z3ext.controlpanel.README.ITestConfiglet2"
+ ... title="Test configlet3">
+ ... </z3ext:configlet>
+ ... </configure>""")
+
+ >>> configlet = component.getUtility(interfaces.IConfiglet, 'configlet3')
+ >>> isinstance(configlet, TestConfiglet1)
+ True
+
+
+Configlet groups
+----------------
+
+The configlet would not be very powerful, if you could create a full
+settingss. So let's create a sub-configlet for settings:
+
+ >>> len(configlet)
+ 0
+
+ >>> 'configlet' in configlet
+ False
+
+ >>> configlet.get('configlet') is None
+ True
+
+ >>> configlet['configlet']
+ Traceback (most recent call last):
+ ...
+ KeyError: 'configlet'
+
+ >>> context = xmlconfig.string("""
+ ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext"
+ ... i18n_domain="zope">
+ ... <include package="z3ext.controlpanel" file="meta.zcml" />
+ ... <z3ext:configlet
+ ... name="configlet3.configlet"
+ ... schema="z3ext.controlpanel.README.ITestConfiglet1"
+ ... title="Test configlet4">
+ ... </z3ext:configlet>
+ ... </configure>""", context)
+
+ >>> configlet['configlet'].__parent__ is configlet
+ True
+
+ >>> len(configlet)
+ 1
+
+ >>> 'configlet' in configlet
+ True
+
+ >>> configlet['configlet'].__id__
+ u'configlet3.configlet'
+
+ >>> configlet.items()
+ [(u'configlet', <z3ext.controlpanel.configlettype.Configlet<configlet3.configlet> ...)]
+
+ >>> configlet.values()
+ [<z3ext.controlpanel.configlettype.Configlet<configlet3.configlet> ...>]
+
+ >>> list(iter(configlet))
+ [<z3ext.controlpanel.configlettype.Configlet<configlet3.configlet> ...>]
+
+
+Configlet availability
+----------------------
+
+We can check availability
+
+ >>> def testConfiglet1(configlet):
+ ... return True
+
+ >>> def testConfiglet2(configlet):
+ ... return False
+
+ >>> c1 = configlet['configlet']
+ >>> c1.isAvailable()
+ True
+
+ >>> c1.__tests__ = (testConfiglet2,)
+ >>> c1.isAvailable()
+ False
+
+Avialability automaticly checks in parent configlet
+
+ >>> c1.__tests__ = (testConfiglet1,)
+ >>> c1.isAvailable()
+ True
+
+ >>> configlet.__tests__ = (testConfiglet2,)
+
+ >>> c1.isAvailable()
+ False
+
+ >>> c1.__tests__ = (testConfiglet1, testConfiglet2)
+ >>> c1.isAvailable()
+ False
+
+ >>> configlet.remove('configlet')
+ >>> len(configlet)
+ 0
+
+We can add custom availability checks in z3ext:configlet directory
+
+ >>> t = xmlconfig.string("""
+ ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext"
+ ... i18n_domain="zope">
+ ... <include package="z3ext.controlpanel" file="meta.zcml" />
+ ... <z3ext:configlet
+ ... name="configlet"
+ ... schema="z3ext.controlpanel.README.ITestConfiglet1"
+ ... tests="z3ext.controlpanel.README.testConfiglet1"
+ ... title="Test configlet">
+ ... </z3ext:configlet>
+ ... </configure>""")
+
+It should be callable
+
+ >>> test = False
+ >>> t = xmlconfig.string("""
+ ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext"
+ ... i18n_domain="zope">
+ ... <include package="z3ext.controlpanel" file="meta.zcml" />
+ ... <z3ext:configlet
+ ... name="configlet"
+ ... schema="z3ext.controlpanel.README.ITestConfiglet1"
+ ... tests="z3ext.controlpanel.README.test"
+ ... title="Test configlet">
+ ... </z3ext:configlet>
+ ... </configure>""")
+ Traceback (most recent call last):
+ ...
+ ZopeXMLConfigurationError: ...
+
+
+Root configlet
+--------------
+
+There is root configlet. You can access any other configlets from root configlet.
+This configlet has no name, so it's available as nameless IConfiglet utility:
+
+ >>> from zope.app.component.hooks import getSite
+
+ >>> root = component.getUtility(interfaces.IConfiglet)
+ >>> root
+ <z3ext.controlpanel.root.RootConfiglet object at ...>
+
+Root configlet parent is ISite object
+
+ >>> root.__parent__ is getSite()
+ True
+
+ >>> ITestConfiglet1.providedBy(root['configlet1'])
+ True
Deleted: z3ext.controlpanel/tags/1.2.5/src/z3ext/controlpanel/browser/tests/README.txt
===================================================================
--- z3ext.controlpanel/trunk/src/z3ext/controlpanel/browser/tests/README.txt 2008-08-27 04:31:17 UTC (rev 90378)
+++ z3ext.controlpanel/tags/1.2.5/src/z3ext/controlpanel/browser/tests/README.txt 2008-08-28 09:50:03 UTC (rev 90539)
@@ -1,85 +0,0 @@
-=============
-Control Panel
-=============
-
-We can access controlpanel with following url http://localhost/settings/
-'setting' name availabel for every ISite object.
-
-Let's demonstrate how we can access controlpanel.
-
- >>> from zope import component
- >>> from zope.testbrowser.testing import Browser
-
- >>> browser = Browser()
- >>> browser.handleErrors = False
- >>> browser.open("http://localhost/settings/")
- Traceback (most recent call last):
- ...
- Unauthorized: settings
-
- >>> browser.open("http://localhost/settings/system/")
- Traceback (most recent call last):
- ...
- Unauthorized: settings
-
- >>> browser = Browser()
- >>> browser.addHeader("Authorization", "Basic mgr:mgrpw")
- >>> browser.handleErrors = False
-
-We should have 'System settings' link in ISite actions menu
-
- >>> browser.open("http://localhost/@@contents.html")
- >>> print browser.contents
- <!DOCTYPE html PUBLIC...
- ...<li><a href="settings/">System settings</a></li>...
- <BLANKLINE>
-
- >>> browser.getLink('System settings').click()
- >>> print browser.contents
- <!DOCTYPE html PUBLIC...
- ...System settings...
- <BLANKLINE>
-
-Configlet categories, by default only first level of categories is
-shown. And only categories that have visible configlets.
-
- >>> 'Category1' in browser.contents
- False
-
- >>> 'Category2' in browser.contents
- True
-
-Also controlponal show configlets in toplevel categories
-
- >>> 'Configlet1' in browser.contents
- True
-
-Category shows only its configlets
-
- >>> browser.open("http://localhost/settings/category1/")
- >>> print browser.contents
- <!DOCTYPE html PUBLIC...
- ...Category1...
- ...Category 1 area...
- ...There are no configlets in this category...
- <BLANKLINE>
-
- >>> browser.open("http://localhost/settings/category2/")
- >>> print browser.contents
- <!DOCTYPE html PUBLIC...
- ...Category2...
- ...Category 2 area...
- ...http://localhost/settings/category2/configlet1/...Configlet1...
- ...http://localhost/settings/category2/configlet2/...Configlet2...
- <BLANKLINE>
-
-But it should not show not available configlets.
-
- >>> 'Configlet3' in browser.contents
- False
-
-By default control panel create edit for each configlet, form name 'index.html'
-
- >>> browser.getLink('Configlet1').click()
- >>> browser.getControl(name='form.buttons.save').click()
- >>> browser.getControl(name='form.buttons.cancel').click()
Copied: z3ext.controlpanel/tags/1.2.5/src/z3ext/controlpanel/browser/tests/README.txt (from rev 90537, z3ext.controlpanel/trunk/src/z3ext/controlpanel/browser/tests/README.txt)
===================================================================
--- z3ext.controlpanel/tags/1.2.5/src/z3ext/controlpanel/browser/tests/README.txt (rev 0)
+++ z3ext.controlpanel/tags/1.2.5/src/z3ext/controlpanel/browser/tests/README.txt 2008-08-28 09:50:03 UTC (rev 90539)
@@ -0,0 +1,84 @@
+=============
+Control Panel
+=============
+
+We can access controlpanel with following url http://localhost/settings/
+'setting' name availabel for every ISite object.
+
+Let's demonstrate how we can access controlpanel.
+
+ >>> from zope import component
+ >>> from zope.testbrowser.testing import Browser
+
+ >>> browser = Browser()
+ >>> browser.handleErrors = False
+ >>> browser.open("http://localhost/settings/")
+ Traceback (most recent call last):
+ ...
+ Unauthorized: settings
+
+ >>> browser.open("http://localhost/settings/system/")
+ Traceback (most recent call last):
+ ...
+ Unauthorized: settings
+
+ >>> browser = Browser()
+ >>> browser.addHeader("Authorization", "Basic mgr:mgrpw")
+ >>> browser.handleErrors = False
+
+We should have 'System settings' link in ISite actions menu
+
+ >>> browser.open("http://localhost/@@contents.html")
+ >>> print browser.contents
+ <!DOCTYPE html PUBLIC...
+ ...<li><a href="settings/">System settings</a></li>...
+ <BLANKLINE>
+
+ >>> browser.getLink('System settings').click()
+ >>> print browser.contents
+ <!DOCTYPE html PUBLIC...
+ ...System settings...
+ <BLANKLINE>
+
+Configlet categories, by default only first level of categories is
+shown. And only categories that have visible configlets.
+
+ >>> 'Category1' in browser.contents
+ False
+
+ >>> 'Category2' in browser.contents
+ True
+
+Also controlponal show configlets in toplevel categories
+
+ >>> 'Configlet1' in browser.contents
+ True
+
+Category shows only its configlets
+
+ >>> browser.open("http://localhost/settings/category1/")
+ >>> print browser.contents
+ <!DOCTYPE html PUBLIC...
+ ...Category1...
+ ...Category 1 area...
+ ...There are no configlets in this category...
+ <BLANKLINE>
+
+ >>> browser.open("http://localhost/settings/category2/")
+ >>> print browser.contents
+ <!DOCTYPE html PUBLIC...
+ ...Category2...
+ ...Category 2 area...
+ ...http://localhost/settings/category2/configlet1/...Configlet1...
+ ...http://localhost/settings/category2/configlet2/...Configlet2...
+ <BLANKLINE>
+
+But it should not show not available configlets.
+
+ >>> 'Configlet3' in browser.contents
+ False
+
+By default control panel create edit for each configlet, form name 'index.html'
+
+ >>> browser.getLink('Configlet1').click()
+ >>> browser.getControl(name='form.buttons.save').click()
Deleted: z3ext.controlpanel/tags/1.2.5/src/z3ext/controlpanel/configlet.py
===================================================================
--- z3ext.controlpanel/trunk/src/z3ext/controlpanel/configlet.py 2008-08-27 04:31:17 UTC (rev 90378)
+++ z3ext.controlpanel/tags/1.2.5/src/z3ext/controlpanel/configlet.py 2008-08-28 09:50:03 UTC (rev 90539)
@@ -1,111 +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.
-#
-##############################################################################
-""" Configlet implementation
-
-$Id$
-"""
-from zope import schema, interface
-from zope.location import Location
-from zope.component import getUtility, queryUtility
-from zope.security.proxy import removeSecurityProxy
-from zope.interface.common.mapping import IEnumerableMapping
-
-from interfaces import IConfiglet, IDataStorage
-
-_marker = object()
-
-
-class Configlet(Location):
- interface.implements(IConfiglet, IEnumerableMapping)
-
- def __init__(self, tests=()):
- self.__name__ = self.__id__.rsplit('.', 1)[-1]
- self.__tests__ = tests
- self.__subgroups__ = ()
-
- @property
- def data(self):
- data = getUtility(IDataStorage)
- return removeSecurityProxy(data)[self.__name__]
-
- def isAvailable(self):
- for test in self.__tests__:
- if not test(self):
- return False
-
- if IConfiglet.providedBy(self.__parent__):
- if not self.__parent__.isAvailable():
- return False
-
- return True
-
- def add(self, name):
- if name not in self.__subgroups__:
- self.__subgroups__ = self.__subgroups__ + (name,)
-
- def remove(self, name):
- if name in self.__subgroups__:
- names = list(self.__subgroups__)
- names.remove(name)
- self.__subgroups__ = tuple(names)
-
- # implementation of IEnumerableMapping interface
- def __getitem__(self, key):
- obj = self.get(key, _marker)
- if obj is _marker:
- raise KeyError(key)
- return obj
-
- def get(self, key, default=None):
- id = self.__id__ and self.__id__ + '.' + key or key
- configlet = queryUtility(IConfiglet, id, default)
- if configlet is default:
- return default
- return configlet
-
- def __contains__(self, key):
- return key in self.keys()
-
- def keys(self):
- return self.__subgroups__
-
- def __iter__(self):
- id = self.__id__
- if id:
- id = id + '.'
-
- for key in self.keys():
- name = id + key
- configlet = queryUtility(IConfiglet, name)
- if configlet is not None:
- yield configlet
-
- def values(self):
- return [group for id, group in self.items()]
-
- def items(self):
- id = self.__id__
- if id:
- id = id + '.'
-
- items = []
- for key in self.keys():
- name = id + key
- configlet = queryUtility(IConfiglet, name)
- if configlet is not None:
- items.append((key, configlet))
- return items
-
- def __len__(self):
- return len(self.keys())
Copied: z3ext.controlpanel/tags/1.2.5/src/z3ext/controlpanel/configlet.py (from rev 90537, z3ext.controlpanel/trunk/src/z3ext/controlpanel/configlet.py)
===================================================================
--- z3ext.controlpanel/tags/1.2.5/src/z3ext/controlpanel/configlet.py (rev 0)
+++ z3ext.controlpanel/tags/1.2.5/src/z3ext/controlpanel/configlet.py 2008-08-28 09:50:03 UTC (rev 90539)
@@ -0,0 +1,120 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+""" Configlet implementation
+
+$Id$
+"""
+import traceback
+from zope import schema, interface
+from zope.location import Location
+from zope.component import getUtility, queryUtility
+from zope.security.proxy import removeSecurityProxy
+from zope.interface.common.mapping import IEnumerableMapping
+
+from interfaces import IConfiglet, IDataStorage
+
+_marker = object()
+
+
+class Configlet(Location):
+ interface.implements(IConfiglet, IEnumerableMapping)
+
+ def __init__(self, tests=()):
+ self.__name__ = self.__id__.rsplit('.', 1)[-1]
+ self.__tests__ = tests
+ self.__subgroups__ = ()
+
+ @property
+ def data(self):
+ storage = removeSecurityProxy(getUtility(IDataStorage))
+
+ if self.__id__ in storage:
+ return storage[self.__id__]
+
+ if self.__name__ in storage:
+ storage[self.__id__] = storage[self.__name__]
+ del storage[self.__name__]
+
+ return storage[self.__id__]
+
+ def isAvailable(self):
+ for test in self.__tests__:
+ if not test(self):
+ return False
+
+ if IConfiglet.providedBy(self.__parent__):
+ if not self.__parent__.isAvailable():
+ return False
+
+ return True
+
+ def add(self, name):
+ if name not in self.__subgroups__:
+ self.__subgroups__ = self.__subgroups__ + (name,)
+
+ def remove(self, name):
+ if name in self.__subgroups__:
+ names = list(self.__subgroups__)
+ names.remove(name)
+ self.__subgroups__ = tuple(names)
+
+ # implementation of IEnumerableMapping interface
+ def __getitem__(self, key):
+ obj = self.get(key, _marker)
+ if obj is _marker:
+ raise KeyError(key)
+ return obj
+
+ def get(self, key, default=None):
+ id = self.__id__ and self.__id__ + '.' + key or key
+ configlet = queryUtility(IConfiglet, id, default)
+ if configlet is default:
+ return default
+ return configlet
+
+ def __contains__(self, key):
+ return key in self.keys()
+
+ def keys(self):
+ return self.__subgroups__
+
+ def __iter__(self):
+ id = self.__id__
+ if id:
+ id = id + '.'
+
+ for key in self.keys():
+ name = id + key
+ configlet = queryUtility(IConfiglet, name)
+ if configlet is not None:
+ yield configlet
+
+ def values(self):
+ return [group for id, group in self.items()]
+
+ def items(self):
+ id = self.__id__
+ if id:
+ id = id + '.'
+
+ items = []
+ for key in self.keys():
+ name = id + key
+ configlet = queryUtility(IConfiglet, name)
+ if configlet is not None:
+ items.append((key, configlet))
+ return items
+
+ def __len__(self):
+ return len(self.keys())
Deleted: z3ext.controlpanel/tags/1.2.5/src/z3ext/controlpanel/configure.zcml
===================================================================
--- z3ext.controlpanel/trunk/src/z3ext/controlpanel/configure.zcml 2008-08-27 04:31:17 UTC (rev 90378)
+++ z3ext.controlpanel/tags/1.2.5/src/z3ext/controlpanel/configure.zcml 2008-08-28 09:50:03 UTC (rev 90539)
@@ -1,76 +0,0 @@
-<configure
- xmlns="http://namespaces.zope.org/zope"
- xmlns:z3ext="http://namespaces.zope.org/z3ext"
- i18n_domain="z3ext">
-
- <includeDependencies package="z3ext.controlpanel" />
-
- <permission
- id="z3ext.Configure"
- title="Configure control panel's configlets." />
-
- <utility
- provides=".interfaces.IConfiglet"
- factory=".root.RootConfiglet" />
-
- <class class=".root.RootConfiglet">
- <require
- permission="zope.Public"
- interface=".interfaces.IConfiglet
- zope.interface.common.mapping.IEnumerableMapping" />
- </class>
-
- <!-- data storage -->
- <utility factory=".storage.DataStorage" />
-
- <!-- default categories -->
- <z3ext:configlet
- name="system"
- schema=".interfaces.ISystemConfiglet"
- title="System configuration"
- description="This area allows you to configure system."
- provides=".interfaces.ICategory"
- permission="zope.Public" />
-
- <z3ext:configlet
- name="ui"
- schema=".interfaces.IUIConfiguration"
- title="User interface configuration"
- description="This area allows you to configure portal look&feel."
- provides=".interfaces.ICategory"
- permission="zope.Public" />
-
- <!-- settings view -->
- <adapter
- name="settings"
- for="zope.app.component.interfaces.ISite *"
- provides="zope.interface.Interface"
- factory=".root.getSettings" />
-
- <!-- Configlet publisher -->
- <adapter
- for=".interfaces.IConfiglet *"
- factory="z3c.traverser.traverser.PluggableTraverser"
- provides="zope.publisher.interfaces.IPublishTraverse" />
-
- <subscriber
- for=".interfaces.IConfiglet *"
- provides="z3c.traverser.interfaces.ITraverserPlugin"
- factory="z3c.traverser.traverser.ContainerTraverserPlugin" />
-
- <include package=".browser" />
-
- <!-- Registering documentation with API doc -->
- <configure
- xmlns:apidoc="http://namespaces.zope.org/apidoc"
- xmlns:zcml="http://namespaces.zope.org/zcml"
- zcml:condition="have apidoc">
-
- <apidoc:bookchapter
- id="z3ext-controlpanel"
- title="z3ext.controlpanel - Control Panel"
- doc_path="README.txt"
- parent="z3ext" />
- </configure>
-
-</configure>
Copied: z3ext.controlpanel/tags/1.2.5/src/z3ext/controlpanel/configure.zcml (from rev 90537, z3ext.controlpanel/trunk/src/z3ext/controlpanel/configure.zcml)
===================================================================
--- z3ext.controlpanel/tags/1.2.5/src/z3ext/controlpanel/configure.zcml (rev 0)
+++ z3ext.controlpanel/tags/1.2.5/src/z3ext/controlpanel/configure.zcml 2008-08-28 09:50:03 UTC (rev 90539)
@@ -0,0 +1,78 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:z3ext="http://namespaces.zope.org/z3ext"
+ i18n_domain="z3ext">
+
+ <includeDependencies package="z3ext.controlpanel" />
+
+ <permission
+ id="z3ext.Configure"
+ title="Configure control panel's configlets." />
+
+ <utility
+ provides=".interfaces.IConfiglet"
+ factory=".root.RootConfiglet" />
+
+ <class class=".root.RootConfiglet">
+ <require
+ permission="zope.Public"
+ interface=".interfaces.IConfiglet
+ zope.interface.common.mapping.IEnumerableMapping" />
+ </class>
+
+ <!-- data storage -->
+ <utility factory=".storage.DataStorage" />
+
+ <subscriber handler=".storage.dataStorageCopied" />
+
+ <!-- default categories -->
+ <z3ext:configlet
+ name="system"
+ schema=".interfaces.ISystemConfiglet"
+ title="System configuration"
+ description="This area allows you to configure system."
+ provides=".interfaces.ICategory"
+ permission="zope.Public" />
+
+ <z3ext:configlet
+ name="ui"
+ schema=".interfaces.IUIConfiguration"
+ title="User interface configuration"
+ description="This area allows you to configure portal look&feel."
+ provides=".interfaces.ICategory"
+ permission="zope.Public" />
+
+ <!-- settings view -->
+ <adapter
+ name="settings"
+ for="zope.app.component.interfaces.ISite *"
+ provides="zope.interface.Interface"
+ factory=".root.getSettings" />
+
+ <!-- Configlet publisher -->
+ <adapter
+ for=".interfaces.IConfiglet *"
+ factory="z3c.traverser.traverser.PluggableTraverser"
+ provides="zope.publisher.interfaces.IPublishTraverse" />
+
+ <subscriber
+ for=".interfaces.IConfiglet *"
+ provides="z3c.traverser.interfaces.ITraverserPlugin"
+ factory="z3c.traverser.traverser.ContainerTraverserPlugin" />
+
+ <include package=".browser" />
+
+ <!-- Registering documentation with API doc -->
+ <configure
+ xmlns:apidoc="http://namespaces.zope.org/apidoc"
+ xmlns:zcml="http://namespaces.zope.org/zcml"
+ zcml:condition="have apidoc">
+
+ <apidoc:bookchapter
+ id="z3ext-controlpanel"
+ title="z3ext.controlpanel - Control Panel"
+ doc_path="README.txt"
+ parent="z3ext" />
+ </configure>
+
+</configure>
Deleted: z3ext.controlpanel/tags/1.2.5/src/z3ext/controlpanel/storage.py
===================================================================
--- z3ext.controlpanel/trunk/src/z3ext/controlpanel/storage.py 2008-08-27 04:31:17 UTC (rev 90378)
+++ z3ext.controlpanel/tags/1.2.5/src/z3ext/controlpanel/storage.py 2008-08-28 09:50:03 UTC (rev 90539)
@@ -1,52 +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.
-#
-##############################################################################
-""" IDataStorage implementation
-
-$Id$
-"""
-from BTrees.OOBTree import OOBTree
-
-from zope import interface
-from zope.app.component.hooks import getSite
-from zope.annotation.interfaces import IAnnotations
-from z3ext.controlpanel.interfaces import IDataStorage
-
-key = 'z3ext.controlpanel.Settings'
-_temp = {}
-
-class DataStorage(object):
- interface.implements(IDataStorage)
-
- @property
- def _data(self):
- site = getSite()
- ann = IAnnotations(site, None)
- if ann is None:
- return _temp
-
- storage = ann.get(key)
- if storage is None:
- storage = OOBTree()
- ann[key] = storage
-
- return storage
-
- def __getitem__(self, name):
- data = self._data.get(name)
-
- if data is None:
- data = OOBTree()
- self._data[name] = data
-
- return data
Copied: z3ext.controlpanel/tags/1.2.5/src/z3ext/controlpanel/storage.py (from rev 90537, z3ext.controlpanel/trunk/src/z3ext/controlpanel/storage.py)
===================================================================
--- z3ext.controlpanel/tags/1.2.5/src/z3ext/controlpanel/storage.py (rev 0)
+++ z3ext.controlpanel/tags/1.2.5/src/z3ext/controlpanel/storage.py 2008-08-28 09:50:03 UTC (rev 90539)
@@ -0,0 +1,103 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+""" IDataStorage implementation
+
+$Id$
+"""
+from BTrees.OOBTree import OOBTree
+
+from zope import interface, component, event
+from zope.proxy import removeAllProxies
+from zope.location.pickling import locationCopy
+from zope.location.interfaces import ILocation
+from zope.app.component.hooks import getSite
+from zope.app.component.interfaces import ISite
+from zope.annotation.interfaces import IAnnotations
+from zope.lifecycleevent import ObjectCopiedEvent
+from zope.lifecycleevent.interfaces import IObjectCopiedEvent
+from z3ext.controlpanel.interfaces import IDataStorage
+
+ANNOTATION_KEY = 'z3ext.controlpanel.Settings'
+_temp = {}
+
+
+class DataStorage(object):
+ interface.implements(IDataStorage)
+
+ @property
+ def _data(self):
+ site = getSite()
+ ann = IAnnotations(site, None)
+ if ann is None:
+ return _temp
+
+ storage = ann.get(ANNOTATION_KEY)
+ if storage is None:
+ storage = OOBTree()
+ ann[ANNOTATION_KEY] = storage
+
+ return storage
+
+ def __getitem__(self, name):
+ data = self._data.get(name)
+
+ if data is None:
+ data = OOBTree()
+ self._data[name] = data
+
+ return data
+
+ def __setitem__(self, name, data):
+ self._data[name] = data
+
+ def __delitem__(self, name):
+ if name in self._data:
+ del self._data[name]
+
+ def __contains__(self, name):
+ return name in self._data
+
+
+ at component.adapter(ISite, IObjectCopiedEvent)
+def dataStorageCopied(site, event):
+ ann = IAnnotations(removeAllProxies(event.original), None)
+ if ann is None:
+ return
+
+ oldStorage = ann.get(ANNOTATION_KEY)
+ if oldStorage is None:
+ return
+
+ ann = IAnnotations(removeAllProxies(site), None)
+ if ann is None:
+ return
+
+ newStorage = ann.get(ANNOTATION_KEY)
+ if newStorage is None:
+ newStorage = OOBTree()
+ ann[key] = newStorage
+
+ for key, obj in oldStorage.items():
+ copy = locationCopy(obj)
+
+ if isinstance(obj, OOBTree):
+ for subkey, subobj in obj.items():
+ subcopy = locationCopy(subobj)
+ if ILocation.providedBy(obj):
+ subcopy.__parent__ = subcopy.__name__ = None
+ event.notify(ObjectCopiedEvent(subcopy, subobj))
+
+ copy[subkey] = subcopy
+
+ newStorage[key] = copy
More information about the Checkins
mailing list