[Checkins] SVN: z3ext.controlpanel/tags/1.3.0/ release tag
Nikolay Kim
fafhrd at datacom.kz
Tue Oct 7 09:39:12 EDT 2008
Log message for revision 91847:
release tag
Changed:
A z3ext.controlpanel/tags/1.3.0/
D z3ext.controlpanel/tags/1.3.0/CHANGES.txt
A z3ext.controlpanel/tags/1.3.0/CHANGES.txt
D z3ext.controlpanel/tags/1.3.0/buildout.cfg
A z3ext.controlpanel/tags/1.3.0/buildout.cfg
A z3ext.controlpanel/tags/1.3.0/scripts/
D z3ext.controlpanel/tags/1.3.0/setup.py
A z3ext.controlpanel/tags/1.3.0/setup.py
D z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/README.txt
A z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/README.txt
D z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/browser/category.pt
A z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/browser/category.pt
D z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/browser/configlet.pt
D z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/browser/configure.zcml
A z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/browser/configure.zcml
D z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/browser/layout.pt
A z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/browser/layout.pt
D z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/browser/navigation.pt
A z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/browser/navigation.pt
A z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/browser/styles.css
D z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/configlet.py
A z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/configlet.py
D z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/configlettype.py
A z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/configlettype.py
D z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/configure.zcml
A z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/configure.zcml
A z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/generations/
D z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/interfaces.py
A z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/interfaces.py
A z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/locales/
D z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/root.py
A z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/root.py
A z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/site.txt
D z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/storage.py
A z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/storage.py
D z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/testing.py
A z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/testing.py
D z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/tests.py
A z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/tests.py
-=-
Copied: z3ext.controlpanel/tags/1.3.0 (from rev 91836, z3ext.controlpanel/trunk)
Deleted: z3ext.controlpanel/tags/1.3.0/CHANGES.txt
===================================================================
--- z3ext.controlpanel/trunk/CHANGES.txt 2008-10-07 03:21:17 UTC (rev 91836)
+++ z3ext.controlpanel/tags/1.3.0/CHANGES.txt 2008-10-07 13:39:11 UTC (rev 91847)
@@ -1,112 +0,0 @@
-=======
-CHANGES
-=======
-
-1.2.7 (Unreleased)
-------------------
-
-- Added `settings` traverser
-
-
-1.2.6 (2008-08-28)
-------------------
-
-- Fixed data storage copy
-
-
-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
Copied: z3ext.controlpanel/tags/1.3.0/CHANGES.txt (from rev 91845, z3ext.controlpanel/trunk/CHANGES.txt)
===================================================================
--- z3ext.controlpanel/tags/1.3.0/CHANGES.txt (rev 0)
+++ z3ext.controlpanel/tags/1.3.0/CHANGES.txt 2008-10-07 13:39:11 UTC (rev 91847)
@@ -0,0 +1,116 @@
+=======
+CHANGES
+=======
+
+1.3.0 (2008-10-07)
+------------------
+
+- Added default stylesheets
+
+- Configlet data storage api has been refactored.
+
+- Use z3ext.controlpanel i18n domain
+
+
+1.2.6 (2008-08-28)
+------------------
+
+- Fixed data storage copy
+
+
+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.3.0/buildout.cfg
===================================================================
--- z3ext.controlpanel/trunk/buildout.cfg 2008-10-07 03:21:17 UTC (rev 91836)
+++ z3ext.controlpanel/tags/1.3.0/buildout.cfg 2008-10-07 13:39:11 UTC (rev 91847)
@@ -1,18 +0,0 @@
-[buildout]
-develop = .
-parts = test coverage-test coverage-report
-
-[test]
-recipe = zc.recipe.testrunner
-eggs = z3ext.controlpanel [test]
-
-[coverage-test]
-recipe = zc.recipe.testrunner
-eggs = z3ext.controlpanel [test]
-defaults = ['--coverage', '../../coverage']
-
-[coverage-report]
-recipe = zc.recipe.egg
-eggs = z3c.coverage
-scripts = coverage=coverage-report
-arguments = ('coverage', 'coverage/report')
Copied: z3ext.controlpanel/tags/1.3.0/buildout.cfg (from rev 91845, z3ext.controlpanel/trunk/buildout.cfg)
===================================================================
--- z3ext.controlpanel/tags/1.3.0/buildout.cfg (rev 0)
+++ z3ext.controlpanel/tags/1.3.0/buildout.cfg 2008-10-07 13:39:11 UTC (rev 91847)
@@ -0,0 +1,60 @@
+[buildout]
+develop = .
+parts = test coverage-test coverage-report
+ i18n- i18nall i18ncheck i18ndude
+
+[test]
+recipe = zc.recipe.testrunner
+eggs = z3ext.controlpanel [test]
+
+[coverage-test]
+recipe = zc.recipe.testrunner
+eggs = z3ext.controlpanel [test]
+defaults = ['--coverage', '../../coverage']
+
+[coverage-report]
+recipe = zc.recipe.egg
+eggs = z3c.coverage
+scripts = coverage=coverage-report
+arguments = ('coverage', 'coverage/report')
+
+[i18n-]
+recipe = z3c.recipe.i18n:i18n
+packages = z3ext.controlpanel
+domain = z3ext.controlpanel
+output = ${buildout:directory}/src/z3ext/controlpanel/locales
+eggs = z3ext.controlpanel [test]
+zcml =
+ <configure i18n_domain="zope"
+ xmlns:zcml="http://namespaces.zope.org/zcml"
+ xmlns:browser="http://namespaces.zope.org/browser">
+ <include package="zope.component" 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.contentprovider" />
+ <include package="zope.app.security" />
+ <include package="zope.app.zcmlfiles" />
+ <include package="zope.app.authentication" />
+
+ <include package="z3c.autoinclude" file="meta.zcml" />
+ <include package="z3ext.controlpanel" file="meta.zcml" />
+ <include package="z3ext.controlpanel" />
+ </configure>
+
+[i18nall]
+recipe = buildout_script
+template_dir = ${buildout:directory}/scripts
+template = i18nall.in
+
+[i18ncheck]
+recipe = buildout_script
+template_dir = ${buildout:directory}/scripts
+template = i18ncheck.in
+
+[i18ndude]
+unzip = true
+recipe = zc.recipe.egg
+eggs = i18ndude
Copied: z3ext.controlpanel/tags/1.3.0/scripts (from rev 91845, z3ext.controlpanel/trunk/scripts)
Deleted: z3ext.controlpanel/tags/1.3.0/setup.py
===================================================================
--- z3ext.controlpanel/trunk/setup.py 2008-10-07 03:21:17 UTC (rev 91836)
+++ z3ext.controlpanel/tags/1.3.0/setup.py 2008-10-07 13:39:11 UTC (rev 91847)
@@ -1,88 +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.7dev'
-
-
-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
- )
Copied: z3ext.controlpanel/tags/1.3.0/setup.py (from rev 91845, z3ext.controlpanel/trunk/setup.py)
===================================================================
--- z3ext.controlpanel/tags/1.3.0/setup.py (rev 0)
+++ z3ext.controlpanel/tags/1.3.0/setup.py 2008-10-07 13:39:11 UTC (rev 91847)
@@ -0,0 +1,92 @@
+##############################################################################
+#
+# 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.3.0'
+
+
+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.i18n',
+ 'zope.i18nmessageid',
+ 'zope.viewlet',
+ 'zope.contentprovider',
+ 'zope.cachedescriptors',
+ 'zope.lifecycleevent',
+ 'zope.configuration',
+ 'zope.app.publisher',
+ 'zope.app.component',
+ 'zope.app.security',
+ 'zope.app.container',
+ 'zc.copy',
+ 'z3c.traverser',
+ 'z3c.autoinclude',
+ 'z3ext.layout',
+ 'z3ext.layoutform',
+ 'z3ext.resourcepackage',
+ ],
+ extras_require = dict(test=['zope.securitypolicy',
+ 'zope.app.security',
+ 'zope.app.testing',
+ 'zope.app.zcmlfiles',
+ 'zope.app.folder',
+ 'zope.traversing',
+ 'zope.testing',
+ 'zope.testbrowser',
+ ]),
+ include_package_data = True,
+ zip_safe = False
+ )
Deleted: z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/README.txt
===================================================================
--- z3ext.controlpanel/trunk/src/z3ext/controlpanel/README.txt 2008-10-07 03:21:17 UTC (rev 91836)
+++ z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/README.txt 2008-10-07 13:39:11 UTC (rev 91847)
@@ -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.3.0/src/z3ext/controlpanel/README.txt (from rev 91845, z3ext.controlpanel/trunk/src/z3ext/controlpanel/README.txt)
===================================================================
--- z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/README.txt (rev 0)
+++ z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/README.txt 2008-10-07 13:39:11 UTC (rev 91847)
@@ -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 configlet 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.3.0/src/z3ext/controlpanel/browser/category.pt
===================================================================
--- z3ext.controlpanel/trunk/src/z3ext/controlpanel/browser/category.pt 2008-10-07 03:21:17 UTC (rev 91836)
+++ z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/browser/category.pt 2008-10-07 13:39:11 UTC (rev 91847)
@@ -1,25 +0,0 @@
-<div class="topframe" tal:define="configlets view/data" i18n:domain="z3ext">
- <h1 tal:content="context/__title__">Configlet category</h1>
- <div class="pageDescription"
- tal:content="context/__description__">Description</div>
-
- <div tal:condition="not:configlets" i18n:translate="">
- There are no configlets in this category.
- </div>
-
- <ul class="listing" tal:condition="configlets" metal:define-macro="configlets">
- <li tal:repeat="configlet configlets">
- <div class="icon">
- <tal:block tal:content="structure configlet/icon|nothing" />
- </div>
- <div class="details">
- <a tal:attributes="href string:${configlet/configlet/@@absolute_url}/"
- tal:content="configlet/title"></a>
- <div><tal:block tal:content="configlet/description" /> </div>
- <tal:block define="configlets configlet/items" condition="configlets">
- <metal:block use-macro="view/template/macros/configlets" />
- </tal:block>
- </div>
- </li>
- </ul>
-</div>
Copied: z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/browser/category.pt (from rev 91845, z3ext.controlpanel/trunk/src/z3ext/controlpanel/browser/category.pt)
===================================================================
--- z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/browser/category.pt (rev 0)
+++ z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/browser/category.pt 2008-10-07 13:39:11 UTC (rev 91847)
@@ -0,0 +1,27 @@
+<div class="z-cp-frame" tal:define="configlets view/data"
+ i18n:domain="z3ext.controlpanel">
+ <h1 class="z-cp-title"
+ tal:content="context/__title__">Configlet category</h1>
+ <div class="z-cp-description"
+ tal:content="context/__description__">Description</div>
+
+ <div tal:condition="not:configlets" i18n:translate="">
+ There are no configlets in this category.
+ </div>
+
+ <ul class="z-cp-listing" tal:condition="configlets" metal:define-macro="configlets">
+ <li tal:repeat="configlet configlets">
+ <div class="z-cp-icon">
+ <tal:block tal:content="structure configlet/icon|nothing" />
+ </div>
+ <div class="z-cp-details">
+ <a tal:attributes="href string:${configlet/configlet/@@absolute_url}/"
+ tal:content="configlet/title"></a>
+ <div><tal:block tal:content="configlet/description" /> </div>
+ <tal:block define="configlets configlet/items" condition="configlets">
+ <metal:block use-macro="view/template/macros/configlets" />
+ </tal:block>
+ </div>
+ </li>
+ </ul>
+</div>
Deleted: z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/browser/configlet.pt
===================================================================
--- z3ext.controlpanel/trunk/src/z3ext/controlpanel/browser/configlet.pt 2008-10-07 03:21:17 UTC (rev 91836)
+++ z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/browser/configlet.pt 2008-10-07 13:39:11 UTC (rev 91847)
@@ -1,25 +0,0 @@
-<div class="topframe">
- <form method="post" class="edit-form" enctype="multipart/form-data"
- tal:attributes="action request/URL">
- <h1 tal:content="view/label|nothing">Do something</h1>
- <div class="discreet" tal:content="view/description|nothing"></div>
- <br />
-
- <div class="fieldset">
- <div>
- <tal:block tal:repeat="widget view/widgets">
- <metal:block use-macro="context/@@form_macros/widget_row"/>
- </tal:block>
- </div>
- </div>
-
- <div id="formControls">
- <hr />
- <span class="actionButtons"
- tal:condition="view/availableActions">
- <input tal:repeat="action view/actions"
- tal:replace="structure action/render" />
- </span>
- </div>
- </form>
-</div>
Deleted: z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/browser/configure.zcml
===================================================================
--- z3ext.controlpanel/trunk/src/z3ext/controlpanel/browser/configure.zcml 2008-10-07 03:21:17 UTC (rev 91836)
+++ z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/browser/configure.zcml 2008-10-07 13:39:11 UTC (rev 91847)
@@ -1,72 +0,0 @@
-<configure
- xmlns="http://namespaces.zope.org/zope"
- xmlns:zcml="http://namespaces.zope.org/zcml"
- xmlns:z3ext="http://namespaces.zope.org/z3ext"
- xmlns:browser="http://namespaces.zope.org/browser"
- i18n_domain="z3ext">
-
- <z3ext:layout
- layout="portal"
- name="workspace"
- for="..interfaces.IRootConfiglet"
- template="layout.pt"
- hidden="yes" />
-
- <browser:icon
- name="zmi_icon"
- for="..interfaces.IConfiglet"
- file="preferences-system.png" />
-
- <browser:defaultView
- name="index.html"
- for="..interfaces.IConfiglet" />
-
- <browser:menuItem
- for="..interfaces.IConfiglet"
- title="View"
- menu="zmi_views"
- action="index.html"
- permission="zope.Public" />
-
- <z3ext:pagelet
- name="index.html"
- for="..interfaces.IConfiglet"
- class=".configlet.Configlet"
- permission="zope.Public" />
-
- <z3ext:pagelet
- name="index.html"
- for="..interfaces.ICategory"
- template="category.pt"
- class=".category.CategoryView"
- permission="zope.Public" />
-
- <!-- navigation -->
- <browser:viewletManager
- name="z3ext.controlpanel-navigation"
- provides=".interfaces.IConfigletNavigation"
- template="navigation.pt"
- class=".navigation.Navigation"
- permission="zope.Public" />
-
- <!-- for ILocalSiteManager -->
- <browser:menuItem
- for="zope.app.component.interfaces.ISite"
- menu="zmi_actions"
- title="System settings"
- action="settings/"
- permission="z3ext.Configure" />
-
- <browser:menuItem
- for="zope.app.component.interfaces.ILocalSiteManager"
- menu="zmi_actions"
- title="System settings"
- action="../settings/"
- permission="z3ext.Configure" />
-
- <!-- configlet breadcrumb -->
- <adapter
- zcml:condition="installed z3c.breadcrumb"
- factory=".breadcrumb.ConfigletBreadcrumb" />
-
-</configure>
Copied: z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/browser/configure.zcml (from rev 91845, z3ext.controlpanel/trunk/src/z3ext/controlpanel/browser/configure.zcml)
===================================================================
--- z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/browser/configure.zcml (rev 0)
+++ z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/browser/configure.zcml 2008-10-07 13:39:11 UTC (rev 91847)
@@ -0,0 +1,79 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:zcml="http://namespaces.zope.org/zcml"
+ xmlns:z3ext="http://namespaces.zope.org/z3ext"
+ xmlns:browser="http://namespaces.zope.org/browser"
+ i18n_domain="z3ext.controlpanel">
+
+ <z3ext:layout
+ layout="portal"
+ name="workspace"
+ for="..interfaces.IRootConfiglet"
+ template="layout.pt"
+ hidden="yes" />
+
+ <browser:icon
+ name="zmi_icon"
+ for="..interfaces.IConfiglet"
+ file="preferences-system.png" />
+
+ <browser:defaultView
+ name="index.html"
+ for="..interfaces.IConfiglet" />
+
+ <browser:menuItem
+ for="..interfaces.IConfiglet"
+ title="View"
+ menu="zmi_views"
+ action="index.html"
+ permission="zope.Public" />
+
+ <z3ext:pagelet
+ name="index.html"
+ for="..interfaces.IConfiglet"
+ class=".configlet.Configlet"
+ permission="zope.Public" />
+
+ <z3ext:pagelet
+ name="index.html"
+ for="..interfaces.ICategory"
+ template="category.pt"
+ class=".category.CategoryView"
+ permission="zope.Public" />
+
+ <!-- navigation -->
+ <browser:viewletManager
+ name="z3ext.controlpanel-navigation"
+ provides=".interfaces.IConfigletNavigation"
+ template="navigation.pt"
+ class=".navigation.Navigation"
+ permission="zope.Public" />
+
+ <!-- for ILocalSiteManager -->
+ <browser:menuItem
+ for="zope.app.component.interfaces.ISite"
+ menu="zmi_actions"
+ title="System settings"
+ action="settings/"
+ permission="z3ext.Configure" />
+
+ <browser:menuItem
+ for="zope.app.component.interfaces.ILocalSiteManager"
+ menu="zmi_actions"
+ title="System settings"
+ action="../settings/"
+ permission="z3ext.Configure" />
+
+ <!-- configlet breadcrumb -->
+ <adapter
+ zcml:condition="installed z3c.breadcrumb"
+ factory=".breadcrumb.ConfigletBreadcrumb" />
+
+ <!-- css styles -->
+ <z3ext:resourceinclude
+ name="z3ext-controlpanel.css"
+ library="z3ext"
+ type="stylesheet"
+ file="styles.css" filetype="zrt" />
+
+</configure>
Deleted: z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/browser/layout.pt
===================================================================
--- z3ext.controlpanel/trunk/src/z3ext/controlpanel/browser/layout.pt 2008-10-07 03:21:17 UTC (rev 91836)
+++ z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/browser/layout.pt 2008-10-07 13:39:11 UTC (rev 91847)
@@ -1,14 +0,0 @@
-<div id="z-portal-workspace"
- tal:define="context nocall:maincontext;
- nav provider:z3ext.controlpanel-navigation;
- noNav not:nav; rendered view/render">
- <div class="page">
- <table class="wide" tal:omit-tag="noNav">
- <tr style="vertical-align: top" tal:omit-tag="noNav">
- <td style="padding-right: 1em; width: 200px"
- tal:condition="nav" tal:content="structure nav"></td>
- <td tal:omit-tag="noNav" tal:content="structure rendered"></td>
- </tr>
- </table>
- </div>
-</div>
Copied: z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/browser/layout.pt (from rev 91846, z3ext.controlpanel/trunk/src/z3ext/controlpanel/browser/layout.pt)
===================================================================
--- z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/browser/layout.pt (rev 0)
+++ z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/browser/layout.pt 2008-10-07 13:39:11 UTC (rev 91847)
@@ -0,0 +1,13 @@
+<div id="z-controlpanel"
+ tal:define="context nocall:maincontext;
+ nav provider:z3ext.controlpanel-navigation;
+ noNav not:nav; rendered view/render;
+ dummy resourcepackage:z3ext">
+ <table class="z-cp-layout" tal:omit-tag="noNav">
+ <tr tal:omit-tag="noNav">
+ <td class="z-cp-nav-wrapper"
+ tal:condition="nav" tal:content="structure nav"></td>
+ <td tal:omit-tag="noNav" tal:content="structure rendered"></td>
+ </tr>
+ </table>
+</div>
Deleted: z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/browser/navigation.pt
===================================================================
--- z3ext.controlpanel/trunk/src/z3ext/controlpanel/browser/navigation.pt 2008-10-07 03:21:17 UTC (rev 91836)
+++ z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/browser/navigation.pt 2008-10-07 13:39:11 UTC (rev 91847)
@@ -1,23 +0,0 @@
-<tal:block tal:repeat="viewlet view/viewlets"
- tal:content="structure viewlet/render" />
-
-<div class="x-listing box small">
- <tal:block tal:repeat="item view/data">
- <metal:block metal:define-macro="level">
- <div class="x-listing-item"
- tal:attributes="class python:item['selected'] and 'x-listing-item-selected'
- or 'x-listing-item'">
- <div tal:omit-tag="not:item/level|nothing"
- tal:attributes="class string:level${item/level|nothing}">
- <a tal:attributes="href string:${item/configlet/@@absolute_url}/">
- <al:block tal:content="structure item/icon" />
- <tal:block tal:content="item/title" />
- </a>
- </div>
- </div>
- <tal:block tal:repeat="item item/items">
- <metal:block use-macro="view/template/macros/level"/>
- </tal:block>
- </metal:block>
- </tal:block>
-</div>
Copied: z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/browser/navigation.pt (from rev 91845, z3ext.controlpanel/trunk/src/z3ext/controlpanel/browser/navigation.pt)
===================================================================
--- z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/browser/navigation.pt (rev 0)
+++ z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/browser/navigation.pt 2008-10-07 13:39:11 UTC (rev 91847)
@@ -0,0 +1,23 @@
+<tal:block tal:repeat="viewlet view/viewlets"
+ tal:content="structure viewlet/render" />
+
+<div class="z-cp-nav">
+ <tal:block tal:repeat="item view/data">
+ <metal:block metal:define-macro="level">
+ <div class="z-cp-nav-item"
+ tal:attributes="class python:item['selected'] and 'z-cp-nav-item-selected'
+ or 'z-cp-nav-item'">
+ <div tal:omit-tag="not:item/level|nothing"
+ tal:attributes="class string:z-cp-level${item/level|nothing}">
+ <a tal:attributes="href string:${item/configlet/@@absolute_url}/">
+ <tal:block tal:content="structure item/icon" />
+ <tal:block tal:content="item/title" />
+ </a>
+ </div>
+ </div>
+ <tal:block tal:repeat="item item/items">
+ <metal:block use-macro="view/template/macros/level"/>
+ </tal:block>
+ </metal:block>
+ </tal:block>
+</div>
Copied: z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/browser/styles.css (from rev 91845, z3ext.controlpanel/trunk/src/z3ext/controlpanel/browser/styles.css)
===================================================================
--- z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/browser/styles.css (rev 0)
+++ z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/browser/styles.css 2008-10-07 13:39:11 UTC (rev 91847)
@@ -0,0 +1,170 @@
+/* zrt-cssregistry: */
+
+ at media all {
+
+ #z-controlpanel {
+ padding: 1.5em;
+ border: borderWidth borderStyle globalBorderColor;
+ background-color: globalBackgroundColor;
+ margin: 2em 1.5em 1.5em 1.5em;
+ font-size: 110%;
+ }
+
+ #z-controlpanel h1 {
+ font-weight: bold;
+ }
+
+ #z-controlpanel .z-cp-description {
+ margin-bottom: 1em;
+ }
+
+ #z-controlpanel table.z-cp-layout {
+ width: 100%;
+ }
+
+ #z-controlpanel table.z-cp-layout tr {
+ vertical-align: top;
+ }
+
+ #z-controlpanel .z-cp-frame {
+ padding: 1em;
+ border: borderWidth borderStyle globalExtraBorderColor;
+ background: contentBackgroundColor;
+ }
+
+ #z-controlpanel .z-cp-nav-wrapper {
+ padding-right: 1em;
+ width: 200px;
+ }
+
+ #z-controlpanel .z-cp-nav {
+ border: borderWidth borderStyle globalBorderColor;
+ border-bottom: none;
+ background: contentBackgroundColor;
+ font-size: fontSmallSize;
+ }
+
+ #z-controlpanel .z-cp-nav a {
+ text-decoration: none;
+ }
+
+ #z-controlpanel .z-cp-nav-item {
+ padding: 0.8em 0.4em 0.5em 0.4em;
+ border-bottom: borderWidth borderStyle globalBorderColor;
+ }
+
+ #z-controlpanel .z-cp-nav-item-selected {
+ padding: 0.8em 0.4em 0.5em 0.4em;
+ background-color: globalBackgroundColor;
+ border-bottom: borderWidth borderStyle globalBorderColor;
+ }
+
+ #z-controlpanel .z-cp-nav-item:hover {
+ background-color: globalBackgroundColor;
+ }
+
+ #z-controlpanel .z-cp-nav-item li span {
+ border: 0;
+ border-bottom: 1px dotted discreetColor;
+ }
+
+
+ ul.z-cp-listing {
+ margin: 0.5em 0;
+ list-style: none;
+ list-style-image: none;
+ list-style-type: none;
+ }
+
+ ul.z-cp-listing li {
+ clear: both;
+ margin-bottom: 0.5em;
+ list-style: none;
+ list-style-image: none;
+ }
+
+ ul.z-cp-listing li .z-cp-icon {
+ float: left;
+ padding-top: 8px;
+ padding-right: 0.5em;
+ height: 32px;
+ }
+
+ ul.z-cp-listing li a,
+ ul.z-cp-listing li .z-cp-details a {
+ color: linkColor;
+ border: 0;
+ border-bottom: 1px dotted discreetColor;
+ text-decoration: none;
+ }
+
+ ul.z-cp-listing li a:visited,
+ ul.z-cp-listing li .z-cp-details a:visited {
+ color: linkColor;
+ background-color: transparent;
+ }
+
+ ul.z-cp-listing li a:active,
+ ul.z-cp-listing li .z-cp-details a:active {
+ color: linkColor;
+ background-color: transparent;
+ }
+
+ ul.z-cp-listing li span {
+ border: 0;
+ border-bottom: 1px dotted discreetColor;
+ }
+
+ ul.z-cp-listing li .z-cp-details span a {
+ border-bottom: 0px;
+ }
+
+ ul.z-cp-listing li label {
+ font-weight: bold;
+ border-bottom: borderWidth dotted discreetColor;
+ }
+
+ ul.z-cp-listing li {
+ border: 1px solid contentBackgroundColor;
+ }
+
+ ul.z-cp-listing li .z-cp-details div {
+ color: discreetColor;
+ font-size: fontSmallSize;
+ }
+
+ ul.z-cp-listing li ul.z-cp-listing {
+ margin-left: 1.5em;
+ font-size: 110%;
+ }
+
+ ul.z-cp-listing li .z-cp-details div span {
+ color: discreetColor;
+ font-size: fontSmallSize;
+ border: 0;
+ }
+
+ .z-cp-level1 {
+ padding-left: 0.8em;
+ }
+
+ .z-cp-level2 {
+ padding-left: 1.6em;
+ }
+
+ .z-cp-level3 {
+ padding-left: 2.4em;
+ }
+
+ .z-cp-level4 {
+ padding-left: 3.2em;
+ }
+
+ #z-controlpanel .z-form-add,
+ #z-controlpanel .z-form-edit {
+ border: borderWidth borderStyle globalExtraBorderColor;
+ margin-top: 0em;
+ padding: 1em;
+ background: contentBackgroundColor;
+ }
+}
Deleted: z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/configlet.py
===================================================================
--- z3ext.controlpanel/trunk/src/z3ext/controlpanel/configlet.py 2008-10-07 03:21:17 UTC (rev 91836)
+++ z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/configlet.py 2008-10-07 13:39:11 UTC (rev 91847)
@@ -1,120 +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$
-"""
-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())
Copied: z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/configlet.py (from rev 91845, z3ext.controlpanel/trunk/src/z3ext/controlpanel/configlet.py)
===================================================================
--- z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/configlet.py (rev 0)
+++ z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/configlet.py 2008-10-07 13:39:11 UTC (rev 91847)
@@ -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$
+"""
+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, IConfigletData
+
+_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):
+ return IConfigletData(self)
+
+ 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.3.0/src/z3ext/controlpanel/configlettype.py
===================================================================
--- z3ext.controlpanel/trunk/src/z3ext/controlpanel/configlettype.py 2008-10-07 03:21:17 UTC (rev 91836)
+++ z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/configlettype.py 2008-10-07 13:39:11 UTC (rev 91847)
@@ -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.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]
Copied: z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/configlettype.py (from rev 91845, z3ext.controlpanel/trunk/src/z3ext/controlpanel/configlettype.py)
===================================================================
--- z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/configlettype.py (rev 0)
+++ z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/configlettype.py 2008-10-07 13:39:11 UTC (rev 91847)
@@ -0,0 +1,198 @@
+##############################################################################
+#
+# 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.storage import ConfigletData
+ >>> 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 = ConfigletData()
+
+ 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'
+
+ >>> ob.data['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 \
+ inst.data.get(self.__name, _marker) is not _marker:
+ raise ValueError(self.__name, _(u'Field is readonly'))
+
+ inst.data[self.__name] = value
+
+ def __delete__(self, inst):
+ del inst.data[self.__name]
Deleted: z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/configure.zcml
===================================================================
--- z3ext.controlpanel/trunk/src/z3ext/controlpanel/configure.zcml 2008-10-07 03:21:17 UTC (rev 91836)
+++ z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/configure.zcml 2008-10-07 13:39:11 UTC (rev 91847)
@@ -1,79 +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" />
- <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" />
-
- <adapter factory=".root.Traversable" />
-
- <!-- 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.3.0/src/z3ext/controlpanel/configure.zcml (from rev 91845, z3ext.controlpanel/trunk/src/z3ext/controlpanel/configure.zcml)
===================================================================
--- z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/configure.zcml (rev 0)
+++ z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/configure.zcml 2008-10-07 13:39:11 UTC (rev 91847)
@@ -0,0 +1,100 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:i18n="http://namespaces.zope.org/i18n"
+ xmlns:z3ext="http://namespaces.zope.org/z3ext"
+ i18n_domain="z3ext.controlpanel">
+
+ <includeDependencies package="." />
+
+ <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>
+
+ <!-- configlet data -->
+ <adapter factory=".storage.getConfigletData" />
+ <adapter factory=".storage.getConfigletDataStorage" />
+ <adapter factory=".storage.DefaultConfigletDataFactory" />
+
+ <class class=".storage.ConfigletData">
+ <require
+ permission="zope.ManageApplication"
+ interface="zope.app.container.interfaces.IContainer" />
+ </class>
+
+ <class class=".storage.ConfigletDataStorage">
+ <require
+ permission="zope.ManageApplication"
+ interface="zope.app.container.interfaces.IContainer" />
+ </class>
+
+ <!-- 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>
+
+ <!-- generations -->
+ <utility
+ name="z3ext.controlpanel"
+ provides="zope.app.generations.interfaces.ISchemaManager"
+ component=".generations.schemaManager" />
+
+ <!-- translations -->
+ <i18n:registerTranslations directory="locales"/>
+
+</configure>
Copied: z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/generations (from rev 91845, z3ext.controlpanel/trunk/src/z3ext/controlpanel/generations)
Deleted: z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/interfaces.py
===================================================================
--- z3ext.controlpanel/trunk/src/z3ext/controlpanel/interfaces.py 2008-10-07 03:21:17 UTC (rev 91836)
+++ z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/interfaces.py 2008-10-07 13:39:11 UTC (rev 91847)
@@ -1,76 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2007 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-""" 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 """
Copied: z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/interfaces.py (from rev 91845, z3ext.controlpanel/trunk/src/z3ext/controlpanel/interfaces.py)
===================================================================
--- z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/interfaces.py (rev 0)
+++ z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/interfaces.py 2008-10-07 13:39:11 UTC (rev 91847)
@@ -0,0 +1,78 @@
+##############################################################################
+#
+# 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.controlpanel')
+
+
+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 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 """
+
+
+class IConfigletData(interface.Interface):
+ """ configlet data storage """
+
+
+class IConfigletDataFactory(interface.Interface):
+ """ configlet data factory """
+
+
+class IConfigletDataStorage(interface.Interface):
+ """ container for IConfigletData """
Copied: z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/locales (from rev 91845, z3ext.controlpanel/trunk/src/z3ext/controlpanel/locales)
Deleted: z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/root.py
===================================================================
--- z3ext.controlpanel/trunk/src/z3ext/controlpanel/root.py 2008-10-07 03:21:17 UTC (rev 91836)
+++ z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/root.py 2008-10-07 13:39:11 UTC (rev 91847)
@@ -1,65 +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.traversing.adapters import DefaultTraversable
-
-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)
-
-
-class Traversable(DefaultTraversable):
- component.adapts(ISite)
-
- def traverse(self, name, furtherPath):
- if name == 'settings':
- return getUtility(IConfiglet)
- return super(Traversable, self).traverse(name, furtherPath)
Copied: z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/root.py (from rev 91845, z3ext.controlpanel/trunk/src/z3ext/controlpanel/root.py)
===================================================================
--- z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/root.py (rev 0)
+++ z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/root.py 2008-10-07 13:39:11 UTC (rev 91847)
@@ -0,0 +1,56 @@
+##############################################################################
+#
+# 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.traversing.adapters import DefaultTraversable
+
+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)
Copied: z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/site.txt (from rev 91845, z3ext.controlpanel/trunk/src/z3ext/controlpanel/site.txt)
===================================================================
--- z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/site.txt (rev 0)
+++ z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/site.txt 2008-10-07 13:39:11 UTC (rev 91847)
@@ -0,0 +1,57 @@
+==============
+Site copy/move
+==============
+
+ >>> from zope import component, interface
+ >>> from zope.app.folder.folder import Folder
+ >>> from zope.app.component.site import LocalSiteManager
+ >>> from zope.component.eventtesting import getEvents, clearEvents
+ >>> from zope.app.component.hooks import getSite, setSite
+ >>> from z3ext.controlpanel.interfaces import IConfiglet
+
+ >>> root = getSite()
+
+ >>> site = Folder()
+
+ >>> root['site'] = site
+ >>> root['subfolder'] = Folder()
+
+ >>> sm = LocalSiteManager(site)
+ >>> site.setSiteManager(sm)
+
+ >>> class IMyUtility(interface.Interface):
+ ... pass
+
+
+Register persistent utility
+
+ >>> setSite(site)
+
+ >>> configlet = component.getUtility(IConfiglet)
+ >>> configlet, configlet.data
+
+ >>> myutility = Folder()
+ >>> interface.directlyProvides(myutility, IMyUtility)
+
+ >>> configlet.data['myutility'] = Folder()
+ >>> sm.registerUtility(myutility, IMyUtility, 'my')
+
+ >>> sm.getUtility(IMyUtility, name='my') is myutility
+ True
+
+Copy site
+
+ >>> clearEvents()
+
+ >>> from zope.copypastemove.interfaces import IObjectCopier
+ >>> copier = IObjectCopier(root['site'])
+ >>> copier.copyTo(root['subfolder'])
+ u'site'
+
+ >>> newsite = root['subfolder']['site']
+ >>> newsm = newsite.getSiteManager()
+
+ >>> newsm.getUtility(IMyUtility, name='my') is myutility
+ True
+
+getEvents()
Deleted: z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/storage.py
===================================================================
--- z3ext.controlpanel/trunk/src/z3ext/controlpanel/storage.py 2008-10-07 03:21:17 UTC (rev 91836)
+++ z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/storage.py 2008-10-07 13:39:11 UTC (rev 91847)
@@ -1,108 +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, component, event
-from zope.proxy import removeAllProxies
-from zope.location.pickling import locationCopy
-from zope.location.interfaces import ILocation
-from zope.app.component.interfaces import ISite
-from zope.app.component.hooks import getSite, setSite
-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, appevent):
- oldSite = getSite()
- setSite(site)
-
- ann = IAnnotations(removeAllProxies(appevent.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(subobj):
- subcopy.__parent__ = subcopy.__name__ = None
- event.notify(ObjectCopiedEvent(subcopy, subobj))
-
- copy[subkey] = subcopy
-
- newStorage[key] = copy
-
- setSite(oldSite)
Copied: z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/storage.py (from rev 91845, z3ext.controlpanel/trunk/src/z3ext/controlpanel/storage.py)
===================================================================
--- z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/storage.py (rev 0)
+++ z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/storage.py 2008-10-07 13:39:11 UTC (rev 91847)
@@ -0,0 +1,186 @@
+##############################################################################
+#
+# 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 storage implementation
+
+$Id$
+"""
+from zope import interface, component, event
+from zope.security.proxy import removeSecurityProxy
+from zope.location.interfaces import ILocation
+from zope.lifecycleevent import ObjectCreatedEvent
+from zope.app.container.btree import BTreeContainer
+from zope.app.component.hooks import getSite
+from zope.app.component.interfaces import ILocalSiteManager
+
+from interfaces import IConfiglet, IConfigletData, IRootConfiglet
+from interfaces import IConfigletDataStorage, IConfigletDataFactory
+
+
+class ConfigletDataStorage(BTreeContainer):
+ interface.implements(IConfigletDataStorage)
+
+
+class ConfigletData(BTreeContainer):
+ """
+ >>> data = ConfigletData()
+
+ Simple values saved as object attributes
+
+ >>> data['attr1'] = 'value1'
+ >>> data['attr1']
+ 'value1'
+
+ >>> data.get('attr1')
+ 'value1'
+
+ >>> getattr(data, 'attr1')
+ 'value1'
+
+ >>> 'attr1' in data
+ False
+
+ >>> del data['attr1']
+
+ >>> getattr(data, 'attr1', None) is None
+ True
+
+ >>> data['attr1']
+ Traceback (most recent call last):
+ ...
+ KeyError: 'attr1'
+
+
+ Locatable objects saved as container items
+
+ >>> class Test(object):
+ ... interface.implements(ILocation)
+ ... __parent__ = __name__ = None
+
+ >>> data['attr2'] = Test()
+
+ >>> data['attr2']
+ <z3ext.controlpanel.storage.Test ...>
+
+ >>> data.get('attr2')
+ <z3ext.controlpanel.storage.Test ...>
+
+ >>> hasattr(data, 'attr2')
+ False
+
+ >>> 'attr2' in data
+ True
+
+ >>> data['attr2'].__parent__ is data
+ True
+
+ >>> del data['attr2']
+
+ >>> 'attr2' in data
+ False
+
+ >>> data['attr2']
+ Traceback (most recent call last):
+ ...
+ KeyError: 'attr2'
+
+
+ """
+
+ interface.implements(IConfigletData)
+
+ def get(self, name, default=None):
+ if name in self:
+ return super(ConfigletData, self).__getitem__(name)
+
+ elif hasattr(self, name):
+ return getattr(self, name, default)
+
+ else:
+ return default
+
+ def __getitem__(self, name):
+ if name in self:
+ return super(ConfigletData, self).__getitem__(name)
+
+ elif hasattr(self, name):
+ return getattr(self, name)
+
+ raise KeyError(name)
+
+ def __setitem__(self, name, value):
+ if ILocation.providedBy(value):
+ super(ConfigletData, self).__setitem__(name, value)
+
+ if hasattr(self, name):
+ delattr(self, name)
+
+ else:
+ setattr(self, name, value)
+
+ def __delitem__(self, name):
+ if name in self:
+ super(ConfigletData, self).__delitem__(name)
+
+ if hasattr(self, name):
+ delattr(self, name)
+
+
+ at component.adapter(IConfiglet)
+ at interface.implementer(IConfigletData)
+def getConfigletData(configlet):
+ site = getSite()
+ storage = IConfigletDataStorage(site.getSiteManager())
+
+ if configlet.__id__ not in storage:
+ data = IConfigletDataFactory(configlet)()
+ event.notify(ObjectCreatedEvent(data))
+
+ if IRootConfiglet.providedBy(configlet):
+ if '__rootconfiglet__' not in storage:
+ storage['__rootconfiglet__'] = data
+ return storage['__rootconfiglet__']
+ else:
+ storage[configlet.__id__] = data
+
+ return storage[configlet.__id__]
+
+
+ at component.adapter(ILocalSiteManager)
+ at interface.implementer(IConfigletDataStorage)
+def getConfigletDataStorage(siteManager):
+ sm = removeSecurityProxy(siteManager)
+
+ storage = sm.get('controlpanel', None)
+ if storage is None or not IConfigletDataStorage.providedBy(storage):
+ if storage is not None:
+ del sm['controlpanel']
+
+ storage = ConfigletDataStorage()
+ event.notify(ObjectCreatedEvent(storage))
+ sm['controlpanel'] = storage
+
+ storage = sm['controlpanel']
+
+ return storage
+
+
+class DefaultConfigletDataFactory(object):
+ component.adapts(IConfiglet)
+ interface.implements(IConfigletDataFactory)
+
+ def __init__(self, configlet):
+ self.configlet = configlet
+
+ def __call__(self, *args, **kw):
+ return ConfigletData(*args, **kw)
Deleted: z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/testing.py
===================================================================
--- z3ext.controlpanel/trunk/src/z3ext/controlpanel/testing.py 2008-10-07 03:21:17 UTC (rev 91836)
+++ z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/testing.py 2008-10-07 13:39:11 UTC (rev 91847)
@@ -1,40 +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 z3ext.controlpanel
-
-$Id$
-"""
-import os
-from zope import component
-from zope.app.testing import setup
-from zope.annotation.attribute import AttributeAnnotations
-from zope.app.component.hooks import getSite, setSite
-from zope.app.testing.functional import ZCMLLayer
-
-from z3ext.controlpanel import storage, root, interfaces
-
-
-def setUpControlPanel():
- setup.setUpTraversal()
- setup.setUpSiteManagerLookup()
-
- component.provideAdapter(root.getSettings, name='settings')
- component.provideAdapter(AttributeAnnotations)
- component.provideUtility(storage.DataStorage())
- component.provideUtility(root.RootConfiglet(), interfaces.IConfiglet)
-
-
-z3extControlPanelLayer = ZCMLLayer(
- os.path.join(os.path.split(__file__)[0], 'ftesting.zcml'),
- __name__, 'z3extControlPanelLayer', allow_teardown=True)
Copied: z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/testing.py (from rev 91845, z3ext.controlpanel/trunk/src/z3ext/controlpanel/testing.py)
===================================================================
--- z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/testing.py (rev 0)
+++ z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/testing.py 2008-10-07 13:39:11 UTC (rev 91847)
@@ -0,0 +1,56 @@
+##############################################################################
+#
+# 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 z3ext.controlpanel
+
+$Id$
+"""
+import os
+from zope import component, interface
+from zope.app.testing import setup
+from zope.annotation.attribute import AttributeAnnotations
+from zope.app.component.hooks import getSite, setSite
+from zope.app.testing.functional import ZCMLLayer
+
+from z3ext.controlpanel import storage, root, interfaces
+
+
+controlPanelData = None
+
+ at component.adapter(interface.Interface)
+ at interface.implementer(interfaces.IConfigletDataStorage)
+def getConfigletDataStorage(siteManager):
+ global controlPanelData
+ if controlPanelData is None:
+ controlPanelData = storage.ConfigletDataStorage()
+ return controlPanelData
+
+
+def setUpControlPanel():
+ setup.setUpTraversal()
+ setup.setUpSiteManagerLookup()
+
+ component.provideAdapter(root.getSettings, name='settings')
+ component.provideAdapter(AttributeAnnotations)
+ component.provideUtility(root.RootConfiglet(), interfaces.IConfiglet)
+
+ global controlPanelData
+ controlPanelData = None
+ component.provideAdapter(storage.getConfigletData)
+ component.provideAdapter(getConfigletDataStorage)
+ component.provideAdapter(storage.DefaultConfigletDataFactory)
+
+
+z3extControlPanelLayer = ZCMLLayer(
+ os.path.join(os.path.split(__file__)[0], 'ftesting.zcml'),
+ __name__, 'z3extControlPanelLayer', allow_teardown=True)
Deleted: z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/tests.py
===================================================================
--- z3ext.controlpanel/trunk/src/z3ext/controlpanel/tests.py 2008-10-07 03:21:17 UTC (rev 91836)
+++ z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/tests.py 2008-10-07 13:39:11 UTC (rev 91847)
@@ -1,47 +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 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),
- ))
Copied: z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/tests.py (from rev 91845, z3ext.controlpanel/trunk/src/z3ext/controlpanel/tests.py)
===================================================================
--- z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/tests.py (rev 0)
+++ z3ext.controlpanel/tags/1.3.0/src/z3ext/controlpanel/tests.py 2008-10-07 13:39:11 UTC (rev 91847)
@@ -0,0 +1,70 @@
+##############################################################################
+#
+# 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, component
+from zope.app.testing import setup
+from zope.copypastemove import ObjectCopier
+from zope.component.event import objectEventNotify
+from zope.location.interfaces import ILocation
+from zope.app.component.site import changeSiteConfigurationAfterMove
+from zope.app.component.interfaces import ISite
+from zope.app.container.interfaces import IObjectMovedEvent
+from zope.app.container.contained import dispatchToSublocations
+
+from z3ext.controlpanel.configlet import Configlet
+from z3ext.controlpanel.testing import setUpControlPanel
+
+
+def setUp(test):
+ setup.placefulSetUp(True)
+
+ component.provideAdapter(ObjectCopier)
+ component.provideHandler(objectEventNotify)
+ component.provideHandler(
+ changeSiteConfigurationAfterMove, (ISite, IObjectMovedEvent))
+ component.provideHandler(
+ dispatchToSublocations, (ILocation, IObjectMovedEvent))
+
+ 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.DocFileSuite(
+ 'site.txt',
+ setUp=setUp, tearDown=tearDown,
+ optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS),
+ doctest.DocTestSuite(
+ 'z3ext.controlpanel.storage',
+ optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS),
+ doctest.DocTestSuite(
+ 'z3ext.controlpanel.configlettype',
+ optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS),
+ ))
More information about the Checkins
mailing list