[Checkins] SVN: z3ext.controlpanel/tags/1.2.3/ tag for 1.2.3 release
Nikolay Kim
fafhrd at datacom.kz
Wed May 14 06:07:29 EDT 2008
Log message for revision 86724:
tag for 1.2.3 release
Changed:
A z3ext.controlpanel/tags/1.2.3/
D z3ext.controlpanel/tags/1.2.3/CHANGES.txt
A z3ext.controlpanel/tags/1.2.3/CHANGES.txt
D z3ext.controlpanel/tags/1.2.3/setup.py
A z3ext.controlpanel/tags/1.2.3/setup.py
D z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/README.txt
A z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/README.txt
D z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/configlet.py
A z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/configlet.py
D z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/configlettype.py
A z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/configlettype.py
D z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/configure.zcml
A z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/configure.zcml
D z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/ftesting.zcml
A z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/ftesting.zcml
D z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/i18n.py
D z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/interfaces.py
A z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/interfaces.py
D z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/root.py
A z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/root.py
D z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/storage.py
A z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/storage.py
D z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/tests.py
A z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/tests.py
D z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/zcml.py
A z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/zcml.py
-=-
Copied: z3ext.controlpanel/tags/1.2.3 (from rev 86718, z3ext.controlpanel/trunk)
Deleted: z3ext.controlpanel/tags/1.2.3/CHANGES.txt
===================================================================
--- z3ext.controlpanel/trunk/CHANGES.txt 2008-05-14 04:50:34 UTC (rev 86718)
+++ z3ext.controlpanel/tags/1.2.3/CHANGES.txt 2008-05-14 10:07:29 UTC (rev 86724)
@@ -1,76 +0,0 @@
-=======
-CHANGES
-=======
-
-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.3/CHANGES.txt (from rev 86723, z3ext.controlpanel/trunk/CHANGES.txt)
===================================================================
--- z3ext.controlpanel/tags/1.2.3/CHANGES.txt (rev 0)
+++ z3ext.controlpanel/tags/1.2.3/CHANGES.txt 2008-05-14 10:07:29 UTC (rev 86724)
@@ -0,0 +1,84 @@
+=======
+CHANGES
+=======
+
+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.3/setup.py
===================================================================
--- z3ext.controlpanel/trunk/setup.py 2008-05-14 04:50:34 UTC (rev 86718)
+++ z3ext.controlpanel/tags/1.2.3/setup.py 2008-05-14 10:07:29 UTC (rev 86724)
@@ -1,86 +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.3dev'
-
-
-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',
- '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.3/setup.py (from rev 86723, z3ext.controlpanel/trunk/setup.py)
===================================================================
--- z3ext.controlpanel/tags/1.2.3/setup.py (rev 0)
+++ z3ext.controlpanel/tags/1.2.3/setup.py 2008-05-14 10:07:29 UTC (rev 86724)
@@ -0,0 +1,87 @@
+##############################################################################
+#
+# 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.3'
+
+
+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
+ )
Deleted: z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/README.txt
===================================================================
--- z3ext.controlpanel/trunk/src/z3ext/controlpanel/README.txt 2008-05-14 04:50:34 UTC (rev 86718)
+++ z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/README.txt 2008-05-14 10:07:29 UTC (rev 86724)
@@ -1,302 +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
- >>> context = xmlconfig.string("""
- ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext">
- ... <include package="z3ext.controlpanel" file="meta.zcml" />
- ... </configure>""")
-
- >>> from zope import interface, component
- >>> from z3ext.controlpanel import tests, interfaces
-
-We can register configlet with z3ext:configlet directive.
-
-Let's create simple configlet
-
- >>> context = xmlconfig.string("""
- ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext"
- ... i18n_domain="zope">
- ... <z3ext:configlet
- ... name="configlet1"
- ... schema="z3ext.controlpanel.tests.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
-
- >>> cl1 = component.getUtility(tests.ITestConfiglet1)
- >>> cl is cl1
- True
-
- >>> cl.__schema__
- <InterfaceClass z3ext.controlpanel.tests.ITestConfiglet1>
-
-We can't change __schema__ at runtime
-
- >>> cl.__schema__ = tests.ITestConfiglet2
- Traceback (most recent call last):
- ...
- AttributeError: Can't set __schema__
-
-
-IConfiglet
-----------
-
-Let's access the settings:
-
- >>> 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'
-
-
-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 by 'permission' attribute.
-We can use <require/> and <allow/> subdirectives inside <z3ext:configlet>
-directive.
-
- >>> 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.tests.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.tests.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.tests.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, but it should subclass
-original Configlet class
-
- >>> 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.tests.TestConfiglet1"
- ... schema="z3ext.controlpanel.tests.ITestConfiglet2"
- ... title="Test configlet3">
- ... </z3ext:configlet>
- ... </configure>""")
-
- >>> configlet = component.getUtility(interfaces.IConfiglet, 'configlet3')
- >>> isinstance(configlet, tests.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'
-
- >>> def testConfiglet(configlet):
- ... return True
-
- >>> 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.tests.ITestConfiglet1"
- ... tests="z3ext.controlpanel.tests.testConfiglet1"
- ... 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
-
- >>> c1 = configlet['configlet']
- >>> c1.isAvailable()
- True
-
- >>> c1.__tests__ = (tests.testConfiglet2,)
- >>> c1.isAvailable()
- False
-
-Avialability automaticly checks in parent configlet
-
- >>> c1.__tests__ = (tests.testConfiglet1,)
- >>> c1.isAvailable()
- True
-
- >>> configlet.__tests__ = (tests.testConfiglet2,)
-
- >>> c1.isAvailable()
- False
-
- >>> c1.__tests__ = (tests.testConfiglet1, False)
- >>> c1.isAvailable()
- False
-
- >>> configlet.remove('configlet')
- >>> len(configlet)
- 0
-
-
-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
-
- >>> tests.ITestConfiglet1.providedBy(root['configlet1'])
- True
Copied: z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/README.txt (from rev 86723, z3ext.controlpanel/trunk/src/z3ext/controlpanel/README.txt)
===================================================================
--- z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/README.txt (rev 0)
+++ z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/README.txt 2008-05-14 10:07:29 UTC (rev 86724)
@@ -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.3/src/z3ext/controlpanel/configlet.py
===================================================================
--- z3ext.controlpanel/trunk/src/z3ext/controlpanel/configlet.py 2008-05-14 04:50:34 UTC (rev 86718)
+++ z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/configlet.py 2008-05-14 10:07:29 UTC (rev 86724)
@@ -1,114 +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 callable(test):
- if not test(self):
- return False
- elif not bool(test):
- 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.3/src/z3ext/controlpanel/configlet.py (from rev 86723, z3ext.controlpanel/trunk/src/z3ext/controlpanel/configlet.py)
===================================================================
--- z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/configlet.py (rev 0)
+++ z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/configlet.py 2008-05-14 10:07:29 UTC (rev 86724)
@@ -0,0 +1,111 @@
+##############################################################################
+#
+# 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())
Deleted: z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/configlettype.py
===================================================================
--- z3ext.controlpanel/trunk/src/z3ext/controlpanel/configlettype.py 2008-05-14 04:50:34 UTC (rev 86718)
+++ z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/configlettype.py 2008-05-14 10:07:29 UTC (rev 86724)
@@ -1,192 +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 metaclass
-
-$Id$
-"""
-import sys
-from zope.schema import getFields
-
-from z3ext.controlpanel.i18n import _
-from z3ext.controlpanel.configlet import Configlet
-
-_marker = object()
-
-
-class ConfigletType(type):
- """ Metaclass for all configlets
-
- >>> from zope import interface, schema
- >>> from z3ext.controlpanel import configlettype
-
- >>> class IMyConfiglet(interface.Interface):
- ... title = schema.TextLine(title = u'Title')
-
- >>> class MyConfiglet(object):
- ... pass
-
- >>> ConfigletClass = configlettype.ConfigletType(
- ... 'myconfiglet', IMyConfiglet, MyConfiglet, 'MyConfiglet', '')
-
- New class avilable by it's cname in z3ext.controlpanel.configlettype module
-
- >>> getattr(configlettype, 'Configlet<myconfiglet>') is ConfigletClass
- True
-
- Automaticly generate schema fields to ConfigletProperty
-
- >>> ConfigletClass.title
- <z3ext.controlpanel.configlettype.ConfigletProperty object at ...>
-
- >>> configlet = ConfigletClass()
- >>> configlet
- <z3ext.controlpanel.configlettype.Configlet<myconfiglet> object at ...>
-
- >>> isinstance(configlet, MyConfiglet)
- True
-
- >>> isinstance(configlet, configlettype.Configlet)
- True
-
- We also can use number of base classes
-
- >>> class MyConfiglet2(object):
- ... pass
-
- >>> ConfigletClass = configlettype.ConfigletType(
- ... 'myconfiglet', IMyConfiglet,
- ... (MyConfiglet, MyConfiglet2), 'MyConfiglet', '')
-
- """
-
- def __new__(cls, name, schema, class_=None, *args, **kw):
- cname = 'Configlet<%s>'%name
- if type(class_) is tuple:
- bases = class_ + (Configlet,)
- elif class_ is not None:
- bases = (class_, Configlet)
- else:
- bases = (Configlet,)
-
- tp = type.__new__(cls, str(cname), bases, {})
- setattr(sys.modules['z3ext.controlpanel.configlettype'], cname, tp)
-
- return tp
-
- def __init__(cls, name, schema, class_=None, title='', description=''):
- for f_id in getFields(schema):
- if not hasattr(cls, f_id):
- setattr(cls, f_id, ConfigletProperty(schema[f_id]))
-
- cls.__id__ = unicode(name)
- cls.__title__ = title
- cls.__description__ = description
- cls.__schema__ = DataProperty(schema)
-
-
-class DataProperty(object):
-
- def __init__(self, schema):
- self.schema = schema
-
- def __get__(self, inst, klass):
- return self.schema
-
- def __set__(self, inst, value):
- raise AttributeError("Can't set __schema__")
-
-
-class ConfigletProperty(object):
- """ Special property thats reads and writes values from
- instance's 'data' attribute
-
- Let's define simple schema field
-
- >>> from zope import schema
- >>> field = schema.TextLine(
- ... title = u'Test',
- ... default = u'default value')
- >>> field.__name__ = 'attr1'
-
- Now we need content class
-
- >>> from z3ext.controlpanel.configlettype import ConfigletProperty
- >>> class Content(object):
- ...
- ... attr1 = ConfigletProperty(field)
-
- Lets create class instance and add field values storage
-
- >>> ob = Content()
- >>> ob.data = {}
-
- By default we should get field default value
-
- >>> ob.attr1
- u'default value'
-
- We can set only valid value
-
- >>> ob.attr1 = 'value1'
- Traceback (most recent call last):
- ...
- WrongType: ('value1', <type 'unicode'>)
-
- >>> ob.attr1 = u'value1'
- >>> ob.attr1
- u'value1'
-
- If storage contains field value we shuld get it
-
- >>> ob.data['attr1'] = u'value2'
- >>> ob.attr1
- u'value2'
-
- We can't set value for readonly fields
-
- >>> field.readonly = True
- >>> ob.attr1 = u'value1'
- Traceback (most recent call last):
- ...
- ValueError: ('attr1', 'field is readonly')
-
- """
-
- def __init__(self, field, name=None):
- if name is None:
- name = field.__name__
-
- self.__field = field
- self.__name = name
-
- def __get__(self, inst, klass):
- if inst is None:
- return self
-
- value = inst.data.get(self.__name, _marker)
- if value is _marker:
- return self.__field.default
-
- return value
-
- def __set__(self, inst, value):
- field = self.__field.bind(inst)
- field.validate(value)
- if field.readonly and self.__name in inst.data:
- raise ValueError(self.__name, _(u'Field is readonly'))
- inst.data[self.__name] = value
-
- def __delete__(self, inst):
- if self.__name in inst.data:
- del inst.data[self.__name]
Copied: z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/configlettype.py (from rev 86723, z3ext.controlpanel/trunk/src/z3ext/controlpanel/configlettype.py)
===================================================================
--- z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/configlettype.py (rev 0)
+++ z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/configlettype.py 2008-05-14 10:07:29 UTC (rev 86724)
@@ -0,0 +1,192 @@
+##############################################################################
+#
+# 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 metaclass
+
+$Id$
+"""
+import sys
+from zope.schema import getFields
+
+from z3ext.controlpanel.interfaces import _
+from z3ext.controlpanel.configlet import Configlet
+
+_marker = object()
+
+
+class ConfigletType(type):
+ """ Metaclass for all configlets
+
+ >>> from zope import interface, schema
+ >>> from z3ext.controlpanel import configlettype
+
+ >>> class IMyConfiglet(interface.Interface):
+ ... title = schema.TextLine(title = u'Title')
+
+ >>> class MyConfiglet(object):
+ ... pass
+
+ >>> ConfigletClass = configlettype.ConfigletType(
+ ... 'myconfiglet', IMyConfiglet, MyConfiglet, 'MyConfiglet', '')
+
+ New class avilable by it's cname in z3ext.controlpanel.configlettype module
+
+ >>> getattr(configlettype, 'Configlet<myconfiglet>') is ConfigletClass
+ True
+
+ Automaticly generate schema fields to ConfigletProperty
+
+ >>> ConfigletClass.title
+ <z3ext.controlpanel.configlettype.ConfigletProperty object at ...>
+
+ >>> configlet = ConfigletClass()
+ >>> configlet
+ <z3ext.controlpanel.configlettype.Configlet<myconfiglet> object at ...>
+
+ >>> isinstance(configlet, MyConfiglet)
+ True
+
+ >>> isinstance(configlet, configlettype.Configlet)
+ True
+
+ We also can use number of base classes
+
+ >>> class MyConfiglet2(object):
+ ... pass
+
+ >>> ConfigletClass = configlettype.ConfigletType(
+ ... 'myconfiglet', IMyConfiglet,
+ ... (MyConfiglet, MyConfiglet2), 'MyConfiglet', '')
+
+ """
+
+ def __new__(cls, name, schema, class_=None, *args, **kw):
+ cname = 'Configlet<%s>'%name
+ if type(class_) is tuple:
+ bases = class_ + (Configlet,)
+ elif class_ is not None:
+ bases = (class_, Configlet)
+ else:
+ bases = (Configlet,)
+
+ tp = type.__new__(cls, str(cname), bases, {})
+ setattr(sys.modules['z3ext.controlpanel.configlettype'], cname, tp)
+
+ return tp
+
+ def __init__(cls, name, schema, class_=None, title='', description=''):
+ for f_id in getFields(schema):
+ if not hasattr(cls, f_id):
+ setattr(cls, f_id, ConfigletProperty(schema[f_id]))
+
+ cls.__id__ = unicode(name)
+ cls.__title__ = title
+ cls.__description__ = description
+ cls.__schema__ = DataProperty(schema)
+
+
+class DataProperty(object):
+
+ def __init__(self, schema):
+ self.schema = schema
+
+ def __get__(self, inst, klass):
+ return self.schema
+
+ def __set__(self, inst, value):
+ raise AttributeError("Can't set __schema__")
+
+
+class ConfigletProperty(object):
+ """ Special property thats reads and writes values from
+ instance's 'data' attribute
+
+ Let's define simple schema field
+
+ >>> from zope import schema
+ >>> field = schema.TextLine(
+ ... title = u'Test',
+ ... default = u'default value')
+ >>> field.__name__ = 'attr1'
+
+ Now we need content class
+
+ >>> from z3ext.controlpanel.configlettype import ConfigletProperty
+ >>> class Content(object):
+ ...
+ ... attr1 = ConfigletProperty(field)
+
+ Lets create class instance and add field values storage
+
+ >>> ob = Content()
+ >>> ob.data = {}
+
+ By default we should get field default value
+
+ >>> ob.attr1
+ u'default value'
+
+ We can set only valid value
+
+ >>> ob.attr1 = 'value1'
+ Traceback (most recent call last):
+ ...
+ WrongType: ('value1', <type 'unicode'>)
+
+ >>> ob.attr1 = u'value1'
+ >>> ob.attr1
+ u'value1'
+
+ If storage contains field value we shuld get it
+
+ >>> ob.data['attr1'] = u'value2'
+ >>> ob.attr1
+ u'value2'
+
+ We can't set value for readonly fields
+
+ >>> field.readonly = True
+ >>> ob.attr1 = u'value1'
+ Traceback (most recent call last):
+ ...
+ ValueError: ('attr1', u'Field is readonly')
+
+ """
+
+ def __init__(self, field, name=None):
+ if name is None:
+ name = field.__name__
+
+ self.__field = field
+ self.__name = name
+
+ def __get__(self, inst, klass):
+ if inst is None:
+ return self
+
+ value = inst.data.get(self.__name, _marker)
+ if value is _marker:
+ return self.__field.default
+
+ return value
+
+ def __set__(self, inst, value):
+ field = self.__field.bind(inst)
+ field.validate(value)
+ if field.readonly and self.__name in inst.data:
+ raise ValueError(self.__name, _(u'Field is readonly'))
+ inst.data[self.__name] = value
+
+ def __delete__(self, inst):
+ if self.__name in inst.data:
+ del inst.data[self.__name]
Deleted: z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/configure.zcml
===================================================================
--- z3ext.controlpanel/trunk/src/z3ext/controlpanel/configure.zcml 2008-05-14 04:50:34 UTC (rev 86718)
+++ z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/configure.zcml 2008-05-14 10:07:29 UTC (rev 86724)
@@ -1,76 +0,0 @@
-<configure
- xmlns="http://namespaces.zope.org/zope"
- xmlns:z3ext="http://namespaces.zope.org/z3ext"
- i18n_domain="z3ext">
-
- <autoinclude 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.3/src/z3ext/controlpanel/configure.zcml (from rev 86723, z3ext.controlpanel/trunk/src/z3ext/controlpanel/configure.zcml)
===================================================================
--- z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/configure.zcml (rev 0)
+++ z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/configure.zcml 2008-05-14 10:07:29 UTC (rev 86724)
@@ -0,0 +1,76 @@
+<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>
Deleted: z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/ftesting.zcml
===================================================================
--- z3ext.controlpanel/trunk/src/z3ext/controlpanel/ftesting.zcml 2008-05-14 04:50:34 UTC (rev 86718)
+++ z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/ftesting.zcml 2008-05-14 10:07:29 UTC (rev 86724)
@@ -1,58 +0,0 @@
-<configure
- xmlns="http://namespaces.zope.org/zope"
- i18n_domain="z3ext" package="z3ext.controlpanel">
-
- <!-- This file is the equivalent of site.zcml and it is -->
- <!-- used for functional testing setup -->
-
- <include package="zope.component" file="meta.zcml" />
- <include package="zope.securitypolicy" file="meta.zcml" />
- <include package="zope.viewlet" file="meta.zcml" />
- <include package="zope.app.component" file="meta.zcml" />
- <include package="zope.app.security" file="meta.zcml" />
- <include package="zope.app.pagetemplate" file="meta.zcml" />
-
- <include package="zope.securitypolicy" />
- <include package="zope.contentprovider" />
- <include package="zope.app.security" />
- <include package="zope.app.zcmlfiles" />
- <include package="zope.app.authentication" />
- <include package="zope.session" />
-
- <include package="z3c.autoinclude" file="meta.zcml" />
- <include package="z3ext.controlpanel" file="meta.zcml" />
- <include package="z3ext.controlpanel" />
- <include package="z3ext.controlpanel.browser.tests" />
- <include package="z3ext.portalmessage" />
-
- <securityPolicy
- component="zope.securitypolicy.zopepolicy.ZopeSecurityPolicy" />
-
- <role id="zope.Anonymous" title="Everybody"
- description="All users have this role implicitly" />
- <role id="zope.Manager" title="Site Manager" />
-
- <!-- Replace the following directive if you don't want public access -->
- <grant permission="zope.View"
- role="zope.Anonymous" />
-
- <grant permission="zope.app.dublincore.view"
- role="zope.Anonymous" />
-
- <!-- Principals -->
- <unauthenticatedPrincipal
- id="zope.anybody"
- title="Unauthenticated User" />
-
- <!-- Principal that tests generally run as -->
- <principal
- id="zope.mgr"
- title="Manager"
- login="mgr"
- password="mgrpw" />
-
- <grant role="zope.Manager" principal="zope.mgr" />
-
- <grantAll role="zope.Manager" />
-
-</configure>
Copied: z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/ftesting.zcml (from rev 86723, z3ext.controlpanel/trunk/src/z3ext/controlpanel/ftesting.zcml)
===================================================================
--- z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/ftesting.zcml (rev 0)
+++ z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/ftesting.zcml 2008-05-14 10:07:29 UTC (rev 86724)
@@ -0,0 +1,57 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ i18n_domain="z3ext" package="z3ext">
+
+ <!-- This file is the equivalent of site.zcml and it is -->
+ <!-- used for functional testing setup -->
+
+ <include package="zope.component" file="meta.zcml" />
+ <include package="zope.securitypolicy" file="meta.zcml" />
+ <include package="zope.viewlet" file="meta.zcml" />
+ <include package="zope.app.component" file="meta.zcml" />
+ <include package="zope.app.security" file="meta.zcml" />
+ <include package="zope.app.pagetemplate" file="meta.zcml" />
+
+ <include package="zope.securitypolicy" />
+ <include package="zope.contentprovider" />
+ <include package="zope.app.security" />
+ <include package="zope.app.zcmlfiles" />
+ <include package="zope.app.authentication" />
+ <include package="zope.session" />
+
+ <include package="z3c.autoinclude" file="meta.zcml" />
+ <include package="z3ext.controlpanel" file="meta.zcml" />
+ <include package="z3ext.controlpanel" />
+ <include package="z3ext.controlpanel.browser.tests" />
+
+ <securityPolicy
+ component="zope.securitypolicy.zopepolicy.ZopeSecurityPolicy" />
+
+ <role id="zope.Anonymous" title="Everybody"
+ description="All users have this role implicitly" />
+ <role id="zope.Manager" title="Site Manager" />
+
+ <!-- Replace the following directive if you don't want public access -->
+ <grant permission="zope.View"
+ role="zope.Anonymous" />
+
+ <grant permission="zope.app.dublincore.view"
+ role="zope.Anonymous" />
+
+ <!-- Principals -->
+ <unauthenticatedPrincipal
+ id="zope.anybody"
+ title="Unauthenticated User" />
+
+ <!-- Principal that tests generally run as -->
+ <principal
+ id="zope.mgr"
+ title="Manager"
+ login="mgr"
+ password="mgrpw" />
+
+ <grant role="zope.Manager" principal="zope.mgr" />
+
+ <grantAll role="zope.Manager" />
+
+</configure>
Deleted: z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/i18n.py
===================================================================
--- z3ext.controlpanel/trunk/src/z3ext/controlpanel/i18n.py 2008-05-14 04:50:34 UTC (rev 86718)
+++ z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/i18n.py 2008-05-14 10:07:29 UTC (rev 86724)
@@ -1,19 +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.
-#
-##############################################################################
-""" i18n
-
-$Id$
-"""
-from zope.i18nmessageid import MessageFactory
-_ = MessageFactory('z3ext')
Deleted: z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/interfaces.py
===================================================================
--- z3ext.controlpanel/trunk/src/z3ext/controlpanel/interfaces.py 2008-05-14 04:50:34 UTC (rev 86718)
+++ z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/interfaces.py 2008-05-14 10:07:29 UTC (rev 86724)
@@ -1,73 +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.controlpanel interfaces
-
-$Id$
-"""
-from zope import schema, interface
-from zope.location.interfaces import ILocation
-
-
-class ICategory(interface.Interface):
- """ settings category """
-
-
-class IRootConfiglet(interface.Interface):
- """ root settings configlet """
-
-
-class ISystemConfiglet(interface.Interface):
- """This area allows you to configure system."""
-
-
-class IPrincipalsConfiglet(interface.Interface):
- """ Portal principals related settings """
-
-
-class IUIConfiguration(interface.Interface):
- """ Portal UI related settings """
-
-
-class IDataStorage(interface.Interface):
- """ data storage """
-
- def get(name):
- """ get named data """
-
- def __getitem__(name):
- """ get named data """
-
-
-class IConfiglet(ILocation):
- """A group of settings."""
-
- __id__ = schema.TextLine(
- title = u"Id",
- description = u"The id of the configlet.",
- required = True)
-
- __title__ = schema.TextLine(
- title = u"Title",
- description = u"The title of the configlet used in the UI.",
- required = True)
-
- __description__ = schema.TextLine(
- title = u"Description",
- description = u"The description of the configlet used in the UI.",
- required = False)
-
- __schema__ = interface.Attribute('Configlet schema (readonly)')
-
- def isAvailable():
- """ is configlet available in current site """
Copied: z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/interfaces.py (from rev 86723, z3ext.controlpanel/trunk/src/z3ext/controlpanel/interfaces.py)
===================================================================
--- z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/interfaces.py (rev 0)
+++ z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/interfaces.py 2008-05-14 10:07:29 UTC (rev 86724)
@@ -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.controlpanel interfaces
+
+$Id$
+"""
+from zope import schema, interface
+from zope.location.interfaces import ILocation
+from zope.i18nmessageid import MessageFactory
+
+_ = MessageFactory('z3ext')
+
+
+class ICategory(interface.Interface):
+ """ settings category """
+
+
+class IRootConfiglet(interface.Interface):
+ """ root settings configlet """
+
+
+class ISystemConfiglet(interface.Interface):
+ """This area allows you to configure system."""
+
+
+class IPrincipalsConfiglet(interface.Interface):
+ """ Portal principals related settings """
+
+
+class IUIConfiguration(interface.Interface):
+ """ Portal UI related settings """
+
+
+class IDataStorage(interface.Interface):
+ """ data storage """
+
+ def get(name):
+ """ get named data """
+
+ def __getitem__(name):
+ """ get named data """
+
+
+class IConfiglet(ILocation):
+ """A group of settings."""
+
+ __id__ = schema.TextLine(
+ title = u"Id",
+ description = u"The id of the configlet.",
+ required = True)
+
+ __title__ = schema.TextLine(
+ title = u"Title",
+ description = u"The title of the configlet used in the UI.",
+ required = True)
+
+ __description__ = schema.TextLine(
+ title = u"Description",
+ description = u"The description of the configlet used in the UI.",
+ required = False)
+
+ __schema__ = interface.Attribute('Configlet schema (readonly)')
+
+ def isAvailable():
+ """ is configlet available in current site """
Deleted: z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/root.py
===================================================================
--- z3ext.controlpanel/trunk/src/z3ext/controlpanel/root.py 2008-05-14 04:50:34 UTC (rev 86718)
+++ z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/root.py 2008-05-14 10:07:29 UTC (rev 86724)
@@ -1,56 +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.
-#
-##############################################################################
-""" Root configlet
-
-$Id$
-"""
-from zope import interface, component
-from zope.component import getUtility
-from zope.security import checkPermission
-from zope.security.interfaces import Unauthorized
-
-from zope.app.component.hooks import getSite
-from zope.app.component.interfaces import ISite
-
-from i18n import _
-from configlet import Configlet
-from interfaces import IConfiglet, IRootConfiglet, ICategory
-
-
-class RootConfiglet(Configlet):
- interface.implements(ICategory, IRootConfiglet)
-
- __id__ = ''
- __name__ = 'settings'
- __title__ = _(u'System settings')
- __description__ = ''
- __schema__ = IRootConfiglet
-
- def __init__(self):
- self.__subgroups__ = ()
-
- def isAvailable(self):
- return True
-
- @property
- def __parent__(self):
- return getSite()
-
-
- at interface.implementer(interface.Interface)
- at component.adapter(ISite, interface.Interface)
-def getSettings(site, request):
- if not checkPermission('z3ext.Configure', site):
- raise Unauthorized('settings')
- return getUtility(IConfiglet)
Copied: z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/root.py (from rev 86723, z3ext.controlpanel/trunk/src/z3ext/controlpanel/root.py)
===================================================================
--- z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/root.py (rev 0)
+++ z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/root.py 2008-05-14 10:07:29 UTC (rev 86724)
@@ -0,0 +1,55 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+""" Root configlet
+
+$Id$
+"""
+from zope import interface, component
+from zope.component import getUtility
+from zope.security import checkPermission
+from zope.security.interfaces import Unauthorized
+
+from zope.app.component.hooks import getSite
+from zope.app.component.interfaces import ISite
+
+from configlet import Configlet
+from interfaces import _, IConfiglet, IRootConfiglet, ICategory
+
+
+class RootConfiglet(Configlet):
+ interface.implements(ICategory, IRootConfiglet)
+
+ __id__ = ''
+ __name__ = 'settings'
+ __title__ = _(u'System settings')
+ __description__ = ''
+ __schema__ = IRootConfiglet
+
+ def __init__(self):
+ self.__subgroups__ = ()
+
+ def isAvailable(self):
+ return True
+
+ @property
+ def __parent__(self):
+ return getSite()
+
+
+ at interface.implementer(interface.Interface)
+ at component.adapter(ISite, interface.Interface)
+def getSettings(site, request):
+ if not checkPermission('z3ext.Configure', site):
+ raise Unauthorized('settings')
+ return getUtility(IConfiglet)
Deleted: z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/storage.py
===================================================================
--- z3ext.controlpanel/trunk/src/z3ext/controlpanel/storage.py 2008-05-14 04:50:34 UTC (rev 86718)
+++ z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/storage.py 2008-05-14 10:07:29 UTC (rev 86724)
@@ -1,50 +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):
- try:
- return self._data[name]
- except KeyError:
- self._data[name] = OOBTree()
- return self._data[name]
Copied: z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/storage.py (from rev 86723, z3ext.controlpanel/trunk/src/z3ext/controlpanel/storage.py)
===================================================================
--- z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/storage.py (rev 0)
+++ z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/storage.py 2008-05-14 10:07:29 UTC (rev 86724)
@@ -0,0 +1,52 @@
+##############################################################################
+#
+# 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
Deleted: z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/tests.py
===================================================================
--- z3ext.controlpanel/trunk/src/z3ext/controlpanel/tests.py 2008-05-14 04:50:34 UTC (rev 86718)
+++ z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/tests.py 2008-05-14 10:07:29 UTC (rev 86724)
@@ -1,81 +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 Control Panel tests
-
-$Id$
-"""
-__docformat__ = "reStructuredText"
-
-import unittest, doctest
-from zope import interface, schema
-from zope.app.testing import setup
-from z3ext.controlpanel.configlet import Configlet
-from z3ext.controlpanel.testing import setUpControlPanel
-
-def testConfiglet1(configlet):
- return True
-
-def testConfiglet2(configlet):
- return False
-
-
-class ITestConfiglet1(interface.Interface):
-
- param1 = schema.TextLine(
- title = u'param1',
- default = u'default param1')
-
- param2 = schema.Int(
- title = u'param2',
- default = 10)
-
-
-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')
-
-
-class TestConfiglet1(Configlet):
- pass
-
-
-class TestConfiglet2(object):
- pass
-
-
-def setUp(test):
- setup.placefulSetUp(True)
- setUpControlPanel()
-
-
-def test_suite():
- return unittest.TestSuite((
- doctest.DocFileSuite(
- 'README.txt',
- setUp=setUp, tearDown=setup.placefulTearDown(),
- optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS),
- doctest.DocTestSuite(
- 'z3ext.controlpanel.configlettype',
- optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS),
- ))
Copied: z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/tests.py (from rev 86723, z3ext.controlpanel/trunk/src/z3ext/controlpanel/tests.py)
===================================================================
--- z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/tests.py (rev 0)
+++ z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/tests.py 2008-05-14 10:07:29 UTC (rev 86724)
@@ -0,0 +1,47 @@
+##############################################################################
+#
+# 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 Control Panel tests
+
+$Id$
+"""
+__docformat__ = "reStructuredText"
+
+import unittest, doctest
+from zope import interface, schema
+from zope.app.testing import setup
+from z3ext.controlpanel.configlet import Configlet
+from z3ext.controlpanel.testing import setUpControlPanel
+
+
+def setUp(test):
+ setup.placefulSetUp(True)
+ setUpControlPanel()
+ setup.setUpTestAsModule(test, 'z3ext.controlpanel.README')
+
+
+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.DocTestSuite(
+ 'z3ext.controlpanel.configlettype',
+ optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS),
+ ))
Deleted: z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/zcml.py
===================================================================
--- z3ext.controlpanel/trunk/src/z3ext/controlpanel/zcml.py 2008-05-14 04:50:34 UTC (rev 86718)
+++ z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/zcml.py 2008-05-14 10:07:29 UTC (rev 86724)
@@ -1,219 +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:configlet directive
-
-$Id$
-"""
-from zope import interface
-from zope.schema import getFields
-from zope.interface.common.mapping import IEnumerableMapping
-
-from zope.component import getUtility
-from zope.component.zcml import utility
-from zope.component.interface import provideInterface
-
-from zope.schema.interfaces import IField
-
-from zope.security import checkPermission
-from zope.security.zcml import Permission
-from zope.security.checker import Checker, CheckerPublic
-
-from zope.configuration import fields
-from zope.configuration.exceptions import ConfigurationError
-
-from zope.app.security.protectclass import protectName, protectSetAttribute
-
-from configlet import Configlet
-from configlettype import ConfigletType
-from interfaces import IConfiglet
-
-
-class IConfigletDirective(interface.Interface):
-
- name = fields.PythonIdentifier(
- title = u"Name",
- description = u"Name of the configlet used to access the settings.",
- required = True)
-
- schema = fields.GlobalInterface(
- title = u"Configlet schema",
- description = u"This attribute specifies the schema of the configlet",
- required = True)
-
- title = fields.MessageID(
- title = u"Title",
- description = u"Title of the configlet used in UIs.",
- required = True)
-
- description = fields.MessageID(
- title = u"Description",
- description = u"Description of the configlet used in UIs.",
- required = False)
-
- class_ = fields.GlobalObject(
- title = u"Class",
- description = u'Custom configlet class',
- required = False)
-
- provides = fields.Tokens(
- title = u'Provides',
- required = False,
- value_type = fields.GlobalInterface())
-
- permission = Permission(
- title = u'Permission',
- description = u'Default access permission.',
- required = False)
-
- tests = fields.Tokens(
- title = u"Tests",
- description = u'Tests for check availability.',
- value_type = fields.GlobalObject(),
- required = False)
-
-
-class ConfigletDirective(object):
-
- def __init__(self, _context, name, schema, title,
- description='', class_=None, provides=(),
- permission='z3ext.Configure', tests=(), install_schema_utility=True):
-
- ConfigletClass = ConfigletType(
- str(name), schema, class_, title, description)
-
- if permission == 'zope.Public':
- configlet = ConfigletClass(tuple(tests))
- else:
- configlet = ConfigletClass(
- (PermissionChecker(permission),) + tuple(tests))
-
- utility(_context, IConfiglet, configlet, name=name)
-
- if install_schema_utility:
- utility(_context, schema, configlet)
-
- interface.classImplements(ConfigletClass, schema, *provides)
-
- self._class = ConfigletClass
- self._context = _context
- self._configlet = configlet
- self._permission = permission
-
- self.require(_context, permission,
- interface=(IConfiglet, schema), set_schema=(schema,))
- self.require(_context, CheckerPublic, interface=(IEnumerableMapping,))
- self.require(_context, CheckerPublic, attributes=('isAvailable',))
-
- _context.action(
- discriminator=('z3ext:controlpanel', configlet),
- callable=addSubgroup, args=(configlet,))
-
- def require(self, _context,
- permission=None, attributes=None, interface=None,
- like_class=None, set_attributes=None, set_schema=None):
- """Require a permission to access a specific aspect"""
- if not (interface or attributes or set_attributes or set_schema):
- raise ConfigurationError("Nothing required")
-
- if not permission:
- raise ConfigurationError("No permission specified")
-
- if interface:
- for i in interface:
- if i:
- self.__protectByInterface(i, permission)
-
- if attributes:
- self.__protectNames(attributes, permission)
-
- if set_attributes:
- self.__protectSetAttributes(set_attributes, permission)
-
- if set_schema:
- for s in set_schema:
- self.__protectSetSchema(s, permission)
-
- def allow(self, _context, attributes=None, interface=None):
- """Like require, but with permission_id zope.Public"""
- return self.require(_context, self._permission, attributes, interface)
-
- def __protectByInterface(self, interface, permission_id):
- "Set a permission on names in an interface."
- for n, d in interface.namesAndDescriptions(1):
- self.__protectName(n, permission_id)
-
- self._context.action(
- discriminator = None,
- callable = provideInterface,
- args = (interface.__module__+'.'+interface.getName(), interface))
-
- def __protectName(self, name, permission_id):
- "Set a permission on a particular name."
- self._context.action(
- discriminator = ('z3ext:controlpanel:protectName',
- self._class, name, object()),
- callable = protectName,
- args = (self._class, name, permission_id))
-
- def __protectNames(self, names, permission_id):
- "Set a permission on a bunch of names."
- for name in names:
- self.__protectName(name, permission_id)
-
- def __protectSetAttributes(self, names, permission_id):
- "Set a permission on a bunch of names."
- for name in names:
- self._context.action(
- discriminator = ('z3ext:controlpanel:protectSetAttribute',
- self._class, name, object()),
- callable = protectSetAttribute,
- args = (self._class, name, permission_id))
-
- def __protectSetSchema(self, schema, permission_id):
- "Set a permission on a bunch of names."
- _context = self._context
-
- for name in schema:
- field = schema[name]
- if IField.providedBy(field) and not field.readonly:
- _context.action(
- discriminator = ('z3ext:controlpanel:protectSetAttribute',
- self._class, name, object()),
- callable = protectSetAttribute,
- args = (self._class, name, permission_id))
-
- _context.action(
- discriminator = None,
- callable = provideInterface,
- args = (schema.__module__+'.'+schema.getName(), schema))
-
-
-def addSubgroup(configlet):
- if '.' in configlet.__id__:
- parentId = configlet.__id__.rsplit('.', 1)[0]
- else:
- parentId = ''
-
- parent = getUtility(IConfiglet, parentId)
- parent.add(configlet.__name__)
- configlet.__parent__ = parent
-
-
-class PermissionChecker(object):
-
- def __init__(self, permission):
- self.permission = permission
-
- def __call__(self, configlet):
- return checkPermission(self.permission, configlet)
Copied: z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/zcml.py (from rev 86723, z3ext.controlpanel/trunk/src/z3ext/controlpanel/zcml.py)
===================================================================
--- z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/zcml.py (rev 0)
+++ z3ext.controlpanel/tags/1.2.3/src/z3ext/controlpanel/zcml.py 2008-05-14 10:07:29 UTC (rev 86724)
@@ -0,0 +1,223 @@
+##############################################################################
+#
+# 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:configlet directive
+
+$Id$
+"""
+from zope import interface
+from zope.schema import getFields
+from zope.interface.common.mapping import IEnumerableMapping
+
+from zope.component import getUtility
+from zope.component.zcml import utility
+from zope.component.interface import provideInterface
+
+from zope.schema.interfaces import IField
+
+from zope.security import checkPermission
+from zope.security.zcml import Permission
+from zope.security.checker import Checker, CheckerPublic
+
+from zope.configuration import fields
+from zope.configuration.exceptions import ConfigurationError
+
+from zope.app.security.protectclass import protectName, protectSetAttribute
+
+from configlet import Configlet
+from configlettype import ConfigletType
+from interfaces import IConfiglet
+
+
+class IConfigletDirective(interface.Interface):
+
+ name = fields.PythonIdentifier(
+ title = u"Name",
+ description = u"Name of the configlet used to access the settings.",
+ required = True)
+
+ schema = fields.GlobalInterface(
+ title = u"Configlet schema",
+ description = u"This attribute specifies the schema of the configlet",
+ required = True)
+
+ title = fields.MessageID(
+ title = u"Title",
+ description = u"Title of the configlet used in UIs.",
+ required = True)
+
+ description = fields.MessageID(
+ title = u"Description",
+ description = u"Description of the configlet used in UIs.",
+ required = False)
+
+ class_ = fields.GlobalObject(
+ title = u"Class",
+ description = u'Custom configlet class',
+ required = False)
+
+ provides = fields.Tokens(
+ title = u'Provides',
+ required = False,
+ value_type = fields.GlobalInterface())
+
+ permission = Permission(
+ title = u'Permission',
+ description = u'Default access permission.',
+ required = False)
+
+ tests = fields.Tokens(
+ title = u"Tests",
+ description = u'Tests for check availability.',
+ value_type = fields.GlobalObject(),
+ required = False)
+
+
+class ConfigletDirective(object):
+
+ def __init__(self, _context, name, schema, title,
+ description='', class_=None, provides=(),
+ permission='z3ext.Configure', tests=(), install_schema_utility=True):
+
+ ConfigletClass = ConfigletType(
+ str(name), schema, class_, title, description)
+
+ for test in tests:
+ if not callable(test):
+ raise ConfigurationError("Test should be callable.")
+
+ if permission == 'zope.Public':
+ configlet = ConfigletClass(tuple(tests))
+ else:
+ configlet = ConfigletClass((
+ PermissionChecker(permission),) + tuple(tests))
+
+ utility(_context, IConfiglet, configlet, name=name)
+
+ if install_schema_utility:
+ utility(_context, schema, configlet)
+
+ interface.classImplements(ConfigletClass, schema, *provides)
+
+ self._class = ConfigletClass
+ self._context = _context
+ self._configlet = configlet
+ self._permission = permission
+
+ self.require(_context, permission,
+ interface=(IConfiglet, schema), set_schema=(schema,))
+ self.require(_context, CheckerPublic, interface=(IEnumerableMapping,))
+ self.require(_context, CheckerPublic, attributes=('isAvailable',))
+
+ _context.action(
+ discriminator=('z3ext:controlpanel', configlet),
+ callable=addSubgroup, args=(configlet,))
+
+ def require(self, _context,
+ permission=None, attributes=None, interface=None,
+ like_class=None, set_attributes=None, set_schema=None):
+ """Require a permission to access a specific aspect"""
+ if not (interface or attributes or set_attributes or set_schema):
+ raise ConfigurationError("Nothing required")
+
+ if not permission:
+ raise ConfigurationError("No permission specified")
+
+ if interface:
+ for i in interface:
+ if i:
+ self.__protectByInterface(i, permission)
+
+ if attributes:
+ self.__protectNames(attributes, permission)
+
+ if set_attributes:
+ self.__protectSetAttributes(set_attributes, permission)
+
+ if set_schema:
+ for s in set_schema:
+ self.__protectSetSchema(s, permission)
+
+ def allow(self, _context, attributes=None, interface=None):
+ """Like require, but with permission_id zope.Public"""
+ return self.require(_context, self._permission, attributes, interface)
+
+ def __protectByInterface(self, interface, permission_id):
+ "Set a permission on names in an interface."
+ for n, d in interface.namesAndDescriptions(1):
+ self.__protectName(n, permission_id)
+
+ self._context.action(
+ discriminator = None,
+ callable = provideInterface,
+ args = (interface.__module__+'.'+interface.getName(), interface))
+
+ def __protectName(self, name, permission_id):
+ "Set a permission on a particular name."
+ self._context.action(
+ discriminator = ('z3ext:controlpanel:protectName',
+ self._class, name, object()),
+ callable = protectName,
+ args = (self._class, name, permission_id))
+
+ def __protectNames(self, names, permission_id):
+ "Set a permission on a bunch of names."
+ for name in names:
+ self.__protectName(name, permission_id)
+
+ def __protectSetAttributes(self, names, permission_id):
+ "Set a permission on a bunch of names."
+ for name in names:
+ self._context.action(
+ discriminator = ('z3ext:controlpanel:protectSetAttribute',
+ self._class, name, object()),
+ callable = protectSetAttribute,
+ args = (self._class, name, permission_id))
+
+ def __protectSetSchema(self, schema, permission_id):
+ "Set a permission on a bunch of names."
+ _context = self._context
+
+ for name in schema:
+ field = schema[name]
+ if IField.providedBy(field) and not field.readonly:
+ _context.action(
+ discriminator = ('z3ext:controlpanel:protectSetAttribute',
+ self._class, name, object()),
+ callable = protectSetAttribute,
+ args = (self._class, name, permission_id))
+
+ _context.action(
+ discriminator = None,
+ callable = provideInterface,
+ args = (schema.__module__+'.'+schema.getName(), schema))
+
+
+def addSubgroup(configlet):
+ if '.' in configlet.__id__:
+ parentId = configlet.__id__.rsplit('.', 1)[0]
+ else:
+ parentId = ''
+
+ parent = getUtility(IConfiglet, parentId)
+ parent.add(configlet.__name__)
+ configlet.__parent__ = parent
+
+
+class PermissionChecker(object):
+
+ def __init__(self, permission):
+ self.permission = permission
+
+ def __call__(self, configlet):
+ return checkPermission(self.permission, configlet)
More information about the Checkins
mailing list