[Checkins] SVN: z3ext.preferences/tags/1.4.8/ tag
Nikolay Kim
fafhrd91 at gmail.com
Mon Jun 22 01:43:56 EDT 2009
Log message for revision 101205:
tag
Changed:
A z3ext.preferences/tags/1.4.8/
D z3ext.preferences/tags/1.4.8/CHANGES.txt
A z3ext.preferences/tags/1.4.8/CHANGES.txt
D z3ext.preferences/tags/1.4.8/bootstrap.py
A z3ext.preferences/tags/1.4.8/bootstrap.py
D z3ext.preferences/tags/1.4.8/setup.py
A z3ext.preferences/tags/1.4.8/setup.py
D z3ext.preferences/tags/1.4.8/src/z3ext/preferences/browser/breadcrumb.py
A z3ext.preferences/tags/1.4.8/src/z3ext/preferences/browser/breadcrumb.py
D z3ext.preferences/tags/1.4.8/src/z3ext/preferences/browser/index.py
A z3ext.preferences/tags/1.4.8/src/z3ext/preferences/browser/index.py
D z3ext.preferences/tags/1.4.8/src/z3ext/preferences/browser/interfaces.py
A z3ext.preferences/tags/1.4.8/src/z3ext/preferences/browser/interfaces.py
D z3ext.preferences/tags/1.4.8/src/z3ext/preferences/configure.zcml
A z3ext.preferences/tags/1.4.8/src/z3ext/preferences/configure.zcml
D z3ext.preferences/tags/1.4.8/src/z3ext/preferences/interfaces.py
A z3ext.preferences/tags/1.4.8/src/z3ext/preferences/interfaces.py
D z3ext.preferences/tags/1.4.8/src/z3ext/preferences/preferencetype.py
A z3ext.preferences/tags/1.4.8/src/z3ext/preferences/preferencetype.py
D z3ext.preferences/tags/1.4.8/src/z3ext/preferences/publisher.py
A z3ext.preferences/tags/1.4.8/src/z3ext/preferences/publisher.py
D z3ext.preferences/tags/1.4.8/src/z3ext/preferences/roles.py
A z3ext.preferences/tags/1.4.8/src/z3ext/preferences/roles.py
D z3ext.preferences/tags/1.4.8/src/z3ext/preferences/tests/interfaces.py
A z3ext.preferences/tags/1.4.8/src/z3ext/preferences/tests/interfaces.py
D z3ext.preferences/tags/1.4.8/src/z3ext/preferences/zcml.py
A z3ext.preferences/tags/1.4.8/src/z3ext/preferences/zcml.py
-=-
Deleted: z3ext.preferences/tags/1.4.8/CHANGES.txt
===================================================================
--- z3ext.preferences/trunk/CHANGES.txt 2009-06-21 18:55:19 UTC (rev 101203)
+++ z3ext.preferences/tags/1.4.8/CHANGES.txt 2009-06-22 05:43:56 UTC (rev 101205)
@@ -1,144 +0,0 @@
-=======
-CHANGES
-=======
-
-1.4.7 (2009-04-23)
-------------------
-
-- Do not use z3c.autoinclude
-
-- Update styles
-
-
-1.4.6 (2009-03-17)
-------------------
-
-- Fixed preference index view
-
-
-1.4.5 (2009-01-09)
-------------------
-
-- Added 'accesspremission' attribute for preferenceGroup directive
-
-- Fixed security for preference group
-
-
-1.4.4 (2008-12-22)
-------------------
-
-- Use new pagelet api
-
-
-1.4.3 (2008-12-12)
-------------------
-
-- Simplify preferences navigation
-
-- raise Unauthorized exception if unauthenticated user access preferences panel
-
-
-1.4.2 (2008-10-27)
-------------------
-
-- Show preference category if it has editable fields
-
-
-1.4.1 (2008-10-22)
-------------------
-
-- Added translations: ru, nl
-
-
-1.4.0 (2008-10-15)
-------------------
-
-- UI api refactored
-
-- Added default css styles
-
-
-1.3.2 (2008-05-16)
-------------------
-
-- Replace 'autoinclude' with 'includeDependendcies'
-
-
-1.3.1 (2008-05-07)
-------------------
-
-- Fix category rendering
-
-
-1.3.0 (2008-05-06)
-------------------
-
-- UI refactoring
-
-- Do not include permission checker for zope.Public permission
-
-
-1.2.1 (2008-04-22)
-------------------
-
-- Added permission checker to directive
-
-
-1.2.0 (2008-04-18)
-------------------
-
-- 'schema' field for z3ext:preferenceGroup is required now
-
-- Added adapter for IPrincipal to 'schema' with automatic binding
-
-
-1.1.1 (2008-04-15)
-------------------
-
-- Use 'z3ext.ManagePreference' as default preference permission
-
-
-1.1.0 (2008-04-11)
-------------------
-
-- Added 'for' field to z3ext:preferenceGroup directive
-
-
-1.0.2 (2008-04-07)
-------------------
-
-- Fix UI in navigation
-
-
-1.0.1 (2008-04-04)
-------------------
-
-- Fixed group category layout
-
-
-1.0.0 (2008-03-25)
-------------------
-
-- Tests added
-
-- Code moved to svn.zope.org
-
-
-0.9.2 (2008-02-29)
-------------------
-
-- Use z3c.autoinclude
-
-- Added z3c.baseregistry support
-
-
-0.9.1 (2008-02-20)
-------------------
-
-- Use z3ext.layoutform
-
-
-0.9.0 (2008-02-01)
-------------------
-
-- Initial release
Copied: z3ext.preferences/tags/1.4.8/CHANGES.txt (from rev 101204, z3ext.preferences/trunk/CHANGES.txt)
===================================================================
--- z3ext.preferences/tags/1.4.8/CHANGES.txt (rev 0)
+++ z3ext.preferences/tags/1.4.8/CHANGES.txt 2009-06-22 05:43:56 UTC (rev 101205)
@@ -0,0 +1,150 @@
+=======
+CHANGES
+=======
+
+1.4.8 (2009-06-22)
+------------------
+
+- Added 'membership' preference category
+
+
+1.4.7 (2009-04-23)
+------------------
+
+- Do not use z3c.autoinclude
+
+- Update styles
+
+
+1.4.6 (2009-03-17)
+------------------
+
+- Fixed preference index view
+
+
+1.4.5 (2009-01-09)
+------------------
+
+- Added 'accesspremission' attribute for preferenceGroup directive
+
+- Fixed security for preference group
+
+
+1.4.4 (2008-12-22)
+------------------
+
+- Use new pagelet api
+
+
+1.4.3 (2008-12-12)
+------------------
+
+- Simplify preferences navigation
+
+- raise Unauthorized exception if unauthenticated user access preferences panel
+
+
+1.4.2 (2008-10-27)
+------------------
+
+- Show preference category if it has editable fields
+
+
+1.4.1 (2008-10-22)
+------------------
+
+- Added translations: ru, nl
+
+
+1.4.0 (2008-10-15)
+------------------
+
+- UI api refactored
+
+- Added default css styles
+
+
+1.3.2 (2008-05-16)
+------------------
+
+- Replace 'autoinclude' with 'includeDependendcies'
+
+
+1.3.1 (2008-05-07)
+------------------
+
+- Fix category rendering
+
+
+1.3.0 (2008-05-06)
+------------------
+
+- UI refactoring
+
+- Do not include permission checker for zope.Public permission
+
+
+1.2.1 (2008-04-22)
+------------------
+
+- Added permission checker to directive
+
+
+1.2.0 (2008-04-18)
+------------------
+
+- 'schema' field for z3ext:preferenceGroup is required now
+
+- Added adapter for IPrincipal to 'schema' with automatic binding
+
+
+1.1.1 (2008-04-15)
+------------------
+
+- Use 'z3ext.ManagePreference' as default preference permission
+
+
+1.1.0 (2008-04-11)
+------------------
+
+- Added 'for' field to z3ext:preferenceGroup directive
+
+
+1.0.2 (2008-04-07)
+------------------
+
+- Fix UI in navigation
+
+
+1.0.1 (2008-04-04)
+------------------
+
+- Fixed group category layout
+
+
+1.0.0 (2008-03-25)
+------------------
+
+- Tests added
+
+- Code moved to svn.zope.org
+
+
+0.9.2 (2008-02-29)
+------------------
+
+- Use z3c.autoinclude
+
+- Added z3c.baseregistry support
+
+
+0.9.1 (2008-02-20)
+------------------
+
+- Use z3ext.layoutform
+
+
+0.9.0 (2008-02-01)
+------------------
+
+- Initial release
Deleted: z3ext.preferences/tags/1.4.8/bootstrap.py
===================================================================
--- z3ext.preferences/trunk/bootstrap.py 2009-06-21 18:55:19 UTC (rev 101203)
+++ z3ext.preferences/tags/1.4.8/bootstrap.py 2009-06-22 05:43:56 UTC (rev 101205)
@@ -1,77 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2006 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.
-#
-##############################################################################
-"""Bootstrap a buildout-based project
-
-Simply run this script in a directory containing a buildout.cfg.
-The script accepts buildout command-line options, so you can
-use the -c option to specify an alternate configuration file.
-
-$Id$
-"""
-
-import os, shutil, sys, tempfile, urllib2
-
-tmpeggs = tempfile.mkdtemp()
-
-is_jython = sys.platform.startswith('java')
-
-try:
- import pkg_resources
-except ImportError:
- ez = {}
- exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
- ).read() in ez
- ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
-
- import pkg_resources
-
-if sys.platform == 'win32':
- def quote(c):
- if ' ' in c:
- return '"%s"' % c # work around spawn lamosity on windows
- else:
- return c
-else:
- def quote (c):
- return c
-
-cmd = 'from setuptools.command.easy_install import main; main()'
-ws = pkg_resources.working_set
-
-if is_jython:
- import subprocess
-
- assert subprocess.Popen([sys.executable] + ['-c', quote(cmd), '-mqNxd',
- quote(tmpeggs), 'zc.buildout'],
- env=dict(os.environ,
- PYTHONPATH=
- ws.find(pkg_resources.Requirement.parse('setuptools')).location
- ),
- ).wait() == 0
-
-else:
- assert os.spawnle(
- os.P_WAIT, sys.executable, quote (sys.executable),
- '-c', quote (cmd), '-mqNxd', quote (tmpeggs), 'zc.buildout',
- dict(os.environ,
- PYTHONPATH=
- ws.find(pkg_resources.Requirement.parse('setuptools')).location
- ),
- ) == 0
-
-ws.add_entry(tmpeggs)
-ws.require('zc.buildout')
-import zc.buildout.buildout
-zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
-shutil.rmtree(tmpeggs)
Copied: z3ext.preferences/tags/1.4.8/bootstrap.py (from rev 101204, z3ext.preferences/trunk/bootstrap.py)
===================================================================
--- z3ext.preferences/tags/1.4.8/bootstrap.py (rev 0)
+++ z3ext.preferences/tags/1.4.8/bootstrap.py 2009-06-22 05:43:56 UTC (rev 101205)
@@ -0,0 +1,77 @@
+##############################################################################
+#
+# Copyright (c) 2006 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.
+#
+##############################################################################
+"""Bootstrap a buildout-based project
+
+Simply run this script in a directory containing a buildout.cfg.
+The script accepts buildout command-line options, so you can
+use the -c option to specify an alternate configuration file.
+
+$Id$
+"""
+
+import os, shutil, sys, tempfile, urllib2
+
+tmpeggs = tempfile.mkdtemp()
+
+is_jython = sys.platform.startswith('java')
+
+try:
+ import pkg_resources
+except ImportError:
+ ez = {}
+ exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
+ ).read() in ez
+ ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
+
+ import pkg_resources
+
+if sys.platform == 'win32':
+ def quote(c):
+ if ' ' in c:
+ return '"%s"' % c # work around spawn lamosity on windows
+ else:
+ return c
+else:
+ def quote (c):
+ return c
+
+cmd = 'from setuptools.command.easy_install import main; main()'
+ws = pkg_resources.working_set
+
+if is_jython:
+ import subprocess
+
+ assert subprocess.Popen([sys.executable] + ['-c', quote(cmd), '-mqNxd',
+ quote(tmpeggs), 'zc.buildout'],
+ env=dict(os.environ,
+ PYTHONPATH=
+ ws.find(pkg_resources.Requirement.parse('setuptools')).location
+ ),
+ ).wait() == 0
+
+else:
+ assert os.spawnle(
+ os.P_WAIT, sys.executable, quote (sys.executable),
+ '-c', quote (cmd), '-mqNxd', quote (tmpeggs), 'zc.buildout',
+ dict(os.environ,
+ PYTHONPATH=
+ ws.find(pkg_resources.Requirement.parse('setuptools')).location
+ ),
+ ) == 0
+
+ws.add_entry(tmpeggs)
+ws.require('zc.buildout')
+import zc.buildout.buildout
+zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
+shutil.rmtree(tmpeggs)
Deleted: z3ext.preferences/tags/1.4.8/setup.py
===================================================================
--- z3ext.preferences/trunk/setup.py 2009-06-21 18:55:19 UTC (rev 101203)
+++ z3ext.preferences/tags/1.4.8/setup.py 2009-06-22 05:43:56 UTC (rev 101205)
@@ -1,90 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2008 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Setup for z3ext.preferences package
-
-$Id$
-"""
-import sys, os
-from setuptools import setup, find_packages
-
-def read(*rnames):
- return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
-
-version='1.4.8dev'
-
-
-setup(name = 'z3ext.preferences',
- version = version,
- author = 'Nikolay Kim',
- author_email = 'fafhrd91 at gmail.com',
- description = "z3ext principal preferences",
- long_description = (
- 'Detailed Documentation\n' +
- '======================\n'
- + '\n\n' +
- read('src', 'z3ext', 'preferences', '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'],
- url='http://z3ext.net/',
- license='ZPL 2.1',
- packages=find_packages('src'),
- package_dir = {'':'src'},
- namespace_packages=['z3ext'],
- install_requires = ['setuptools',
- 'ZODB3',
- 'zope.component',
- 'zope.interface',
- 'zope.annotation',
- 'zope.publisher',
- 'zope.configuration',
- 'zope.schema',
- 'zope.location',
- 'zope.security',
- 'zope.securitypolicy',
- 'zope.cachedescriptors',
- 'zope.pagetemplate',
- 'zope.i18n',
- 'zope.i18nmessageid',
- 'zope.viewlet',
- 'zope.contentprovider',
- 'zope.app.security',
- 'zope.app.component',
- 'zope.app.publisher',
- 'zope.app.pagetemplate',
- 'zope.app.principalannotation',
- 'z3c.traverser',
- 'z3ext.layout',
- 'z3ext.layoutform',
- 'z3ext.statusmessage',
- 'z3ext.resourcepackage',
- ],
- extras_require = dict(test=['zope.app.testing',
- 'zope.testing',
- 'zope.testbrowser',
- 'zope.app.zcmlfiles',
- ]),
- include_package_data = True,
- zip_safe = False
- )
Copied: z3ext.preferences/tags/1.4.8/setup.py (from rev 101204, z3ext.preferences/trunk/setup.py)
===================================================================
--- z3ext.preferences/tags/1.4.8/setup.py (rev 0)
+++ z3ext.preferences/tags/1.4.8/setup.py 2009-06-22 05:43:56 UTC (rev 101205)
@@ -0,0 +1,90 @@
+##############################################################################
+#
+# Copyright (c) 2008 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Setup for z3ext.preferences package
+
+$Id$
+"""
+import sys, os
+from setuptools import setup, find_packages
+
+def read(*rnames):
+ return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
+
+version='1.4.8dev'
+
+
+setup(name = 'z3ext.preferences',
+ version = version,
+ author = 'Nikolay Kim',
+ author_email = 'fafhrd91 at gmail.com',
+ description = "z3ext principal preferences",
+ long_description = (
+ 'Detailed Documentation\n' +
+ '======================\n'
+ + '\n\n' +
+ read('src', 'z3ext', 'preferences', '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'],
+ url='http://z3ext.net/',
+ license='ZPL 2.1',
+ packages=find_packages('src'),
+ package_dir = {'':'src'},
+ namespace_packages=['z3ext'],
+ install_requires = ['setuptools',
+ 'ZODB3',
+ 'zope.component',
+ 'zope.interface',
+ 'zope.annotation',
+ 'zope.publisher',
+ 'zope.configuration',
+ 'zope.schema',
+ 'zope.location',
+ 'zope.security',
+ 'zope.securitypolicy',
+ 'zope.cachedescriptors',
+ 'zope.pagetemplate',
+ 'zope.i18n',
+ 'zope.i18nmessageid',
+ 'zope.viewlet',
+ 'zope.contentprovider',
+ 'zope.app.security',
+ 'zope.app.component',
+ 'zope.app.publisher',
+ 'zope.app.pagetemplate',
+ 'zope.app.principalannotation',
+ 'z3c.traverser',
+ 'z3ext.layout',
+ 'z3ext.layoutform',
+ 'z3ext.statusmessage',
+ 'z3ext.resourcepackage',
+ ],
+ extras_require = dict(test=['zope.app.testing',
+ 'zope.testing',
+ 'zope.testbrowser',
+ 'zope.app.zcmlfiles',
+ ]),
+ include_package_data = True,
+ zip_safe = False
+ )
Deleted: z3ext.preferences/tags/1.4.8/src/z3ext/preferences/browser/breadcrumb.py
===================================================================
--- z3ext.preferences/trunk/src/z3ext/preferences/browser/breadcrumb.py 2009-06-21 18:55:19 UTC (rev 101203)
+++ z3ext.preferences/tags/1.4.8/src/z3ext/preferences/browser/breadcrumb.py 2009-06-22 05:43:56 UTC (rev 101205)
@@ -1,36 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2004 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.
-#
-##############################################################################
-""" custom IBreadcrumb implementation for IPreferencesGroup
-
-$Id$
-"""
-from zope import interface, component
-from zope.traversing.browser import absoluteURL
-from z3c.breadcrumb.browser import GenericBreadcrumb
-from z3ext.preferences.interfaces import _, IPreferenceGroup
-
-
-class PreferenceGroupBreadcrumb(GenericBreadcrumb):
- component.adapts(IPreferenceGroup, interface.Interface)
-
- @property
- def url(self):
- return '%s/'%(absoluteURL(self.context, self.request))
-
- @property
- def name(self):
- name = self.context.__title__ or self.context.__id__
- if not name:
- name = _(u'Preferences')
- return name
Copied: z3ext.preferences/tags/1.4.8/src/z3ext/preferences/browser/breadcrumb.py (from rev 101204, z3ext.preferences/trunk/src/z3ext/preferences/browser/breadcrumb.py)
===================================================================
--- z3ext.preferences/tags/1.4.8/src/z3ext/preferences/browser/breadcrumb.py (rev 0)
+++ z3ext.preferences/tags/1.4.8/src/z3ext/preferences/browser/breadcrumb.py 2009-06-22 05:43:56 UTC (rev 101205)
@@ -0,0 +1,36 @@
+##############################################################################
+#
+# Copyright (c) 2004 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.
+#
+##############################################################################
+""" custom IBreadcrumb implementation for IPreferencesGroup
+
+$Id$
+"""
+from zope import interface, component
+from zope.traversing.browser import absoluteURL
+from z3c.breadcrumb.browser import GenericBreadcrumb
+from z3ext.preferences.interfaces import _, IPreferenceGroup
+
+
+class PreferenceGroupBreadcrumb(GenericBreadcrumb):
+ component.adapts(IPreferenceGroup, interface.Interface)
+
+ @property
+ def url(self):
+ return '%s/'%(absoluteURL(self.context, self.request))
+
+ @property
+ def name(self):
+ name = self.context.__title__ or self.context.__id__
+ if not name:
+ name = _(u'Preferences')
+ return name
Deleted: z3ext.preferences/tags/1.4.8/src/z3ext/preferences/browser/index.py
===================================================================
--- z3ext.preferences/trunk/src/z3ext/preferences/browser/index.py 2009-06-21 18:55:19 UTC (rev 101203)
+++ z3ext.preferences/tags/1.4.8/src/z3ext/preferences/browser/index.py 2009-06-22 05:43:56 UTC (rev 101205)
@@ -1,51 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2007 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""
-
-$Id$
-"""
-from zope.interface import Interface
-from zope.component import getUtility
-from zope.security import checkPermission
-from z3ext.preferences.utils import hasEditableFields
-from z3ext.preferences.interfaces import IPreferenceGroup, IPreferenceCategory
-
-
-class PreferencesView(object):
-
- def groups(self):
- root = self.context
- request = self.request
-
- groups = []
- for name, group in root.items():
- if not group.isAvailable():
- continue
-
- if IPreferenceCategory.providedBy(group):
- subgroups = [(sgroup.__title__,
- sgroup.__id__.split('.')[-1], sgroup)
- for t, sgroup in group.items()
- if sgroup.isAvailable()]
- if (len(subgroups) > 1) or hasEditableFields(group):
- groups.append((group.__title__, group,
- [{'id': id, 'group': sgroup}
- for t, id, sgroup in subgroups]))
- elif len(subgroups) == 1:
- groups.append((group.__title__, group, ()))
- else:
- groups.append((group.__title__, group, ()))
-
- return [{'group':group, 'subgroups': groups}
- for t, group, groups in groups]
Copied: z3ext.preferences/tags/1.4.8/src/z3ext/preferences/browser/index.py (from rev 101204, z3ext.preferences/trunk/src/z3ext/preferences/browser/index.py)
===================================================================
--- z3ext.preferences/tags/1.4.8/src/z3ext/preferences/browser/index.py (rev 0)
+++ z3ext.preferences/tags/1.4.8/src/z3ext/preferences/browser/index.py 2009-06-22 05:43:56 UTC (rev 101205)
@@ -0,0 +1,51 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+
+$Id$
+"""
+from zope.interface import Interface
+from zope.component import getUtility
+from zope.security import checkPermission
+from z3ext.preferences.utils import hasEditableFields
+from z3ext.preferences.interfaces import IPreferenceGroup, IPreferenceCategory
+
+
+class PreferencesView(object):
+
+ def groups(self):
+ root = self.context
+ request = self.request
+
+ groups = []
+ for name, group in root.items():
+ if not group.isAvailable():
+ continue
+
+ if IPreferenceCategory.providedBy(group):
+ subgroups = [(sgroup.__title__,
+ sgroup.__id__.split('.')[-1], sgroup)
+ for t, sgroup in group.items()
+ if sgroup.isAvailable()]
+ if (len(subgroups) > 1) or hasEditableFields(group):
+ groups.append((group.__title__, group,
+ [{'id': id, 'group': sgroup}
+ for t, id, sgroup in subgroups]))
+ elif len(subgroups) == 1:
+ groups.append((group.__title__, group, ()))
+ else:
+ groups.append((group.__title__, group, ()))
+
+ return [{'group':group, 'subgroups': groups}
+ for t, group, groups in groups]
Deleted: z3ext.preferences/tags/1.4.8/src/z3ext/preferences/browser/interfaces.py
===================================================================
--- z3ext.preferences/trunk/src/z3ext/preferences/browser/interfaces.py 2009-06-21 18:55:19 UTC (rev 101203)
+++ z3ext.preferences/tags/1.4.8/src/z3ext/preferences/browser/interfaces.py 2009-06-22 05:43:56 UTC (rev 101205)
@@ -1,31 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2008 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""
-
-$Id$
-"""
-from zope import interface
-from zope.viewlet.interfaces import IViewletManager
-
-
-class IEdit(interface.Interface):
- """ preference group edit view """
-
-
-class IPreview(interface.Interface):
- """ preference group preview """
-
-
-class IPreferencesNavigation(IViewletManager):
- """ preferences navigation viewlet manager """
Copied: z3ext.preferences/tags/1.4.8/src/z3ext/preferences/browser/interfaces.py (from rev 101204, z3ext.preferences/trunk/src/z3ext/preferences/browser/interfaces.py)
===================================================================
--- z3ext.preferences/tags/1.4.8/src/z3ext/preferences/browser/interfaces.py (rev 0)
+++ z3ext.preferences/tags/1.4.8/src/z3ext/preferences/browser/interfaces.py 2009-06-22 05:43:56 UTC (rev 101205)
@@ -0,0 +1,31 @@
+##############################################################################
+#
+# Copyright (c) 2008 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+
+$Id$
+"""
+from zope import interface
+from zope.viewlet.interfaces import IViewletManager
+
+
+class IEdit(interface.Interface):
+ """ preference group edit view """
+
+
+class IPreview(interface.Interface):
+ """ preference group preview """
+
+
+class IPreferencesNavigation(IViewletManager):
+ """ preferences navigation viewlet manager """
Deleted: z3ext.preferences/tags/1.4.8/src/z3ext/preferences/configure.zcml
===================================================================
--- z3ext.preferences/trunk/src/z3ext/preferences/configure.zcml 2009-06-21 18:55:19 UTC (rev 101203)
+++ z3ext.preferences/tags/1.4.8/src/z3ext/preferences/configure.zcml 2009-06-22 05:43:56 UTC (rev 101205)
@@ -1,61 +0,0 @@
-<configure
- xmlns="http://namespaces.zope.org/zope"
- xmlns:i18n="http://namespaces.zope.org/i18n"
- xmlns:z3ext="http://namespaces.zope.org/z3ext"
- i18n_domain="z3ext.preferences">
-
- <permission
- id="z3ext.ModifyPreference"
- title="Modify preference" />
-
- <role
- id="preference.Owner"
- title="Preference group owner" />
-
- <grant
- permission="z3ext.ModifyPreference"
- role="preference.Owner" />
-
- <!-- default preference group storage -->
- <adapter factory=".storage.getDefaultStorage" />
-
- <!-- root preference group -->
- <utility
- provides=".interfaces.IPreferenceGroup"
- factory=".root.PersonalPreferences" />
-
- <class class=".root.PersonalPreferences">
- <require
- permission="zope.Public"
- interface=".interfaces.IPreferenceGroup
- zope.interface.common.mapping.IEnumerableMapping" />
- </class>
-
- <!-- preference group roles -->
- <adapter factory=".roles.PreferenceGroupRoles" />
-
- <!-- preference group publisher -->
- <adapter
- for=".interfaces.IPreferenceGroup *"
- factory="z3c.traverser.traverser.PluggableTraverser"
- provides="zope.publisher.interfaces.IPublishTraverse" />
-
- <subscriber
- for=".interfaces.IPreferenceGroup *"
- provides="z3c.traverser.interfaces.ITraverserPlugin"
- factory=".publisher.PreferenceTraverserPlugin" />
-
- <!-- predefined preference group -->
- <z3ext:preferenceGroup
- id="portal"
- title="Portal preferences"
- description="These are all the preferences related to common portal settings."
- schema="z3ext.preferences.interfaces.IPortalPreferences" />
-
- <!-- browser views -->
- <include package=".browser" />
-
- <!-- translations -->
- <i18n:registerTranslations directory="locales"/>
-
-</configure>
Copied: z3ext.preferences/tags/1.4.8/src/z3ext/preferences/configure.zcml (from rev 101204, z3ext.preferences/trunk/src/z3ext/preferences/configure.zcml)
===================================================================
--- z3ext.preferences/tags/1.4.8/src/z3ext/preferences/configure.zcml (rev 0)
+++ z3ext.preferences/tags/1.4.8/src/z3ext/preferences/configure.zcml 2009-06-22 05:43:56 UTC (rev 101205)
@@ -0,0 +1,67 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:i18n="http://namespaces.zope.org/i18n"
+ xmlns:z3ext="http://namespaces.zope.org/z3ext"
+ i18n_domain="z3ext.preferences">
+
+ <permission
+ id="z3ext.ModifyPreference"
+ title="Modify preference" />
+
+ <role
+ id="preference.Owner"
+ title="Preference group owner" />
+
+ <grant
+ permission="z3ext.ModifyPreference"
+ role="preference.Owner" />
+
+ <!-- default preference group storage -->
+ <adapter factory=".storage.getDefaultStorage" />
+
+ <!-- root preference group -->
+ <utility
+ provides=".interfaces.IPreferenceGroup"
+ factory=".root.PersonalPreferences" />
+
+ <class class=".root.PersonalPreferences">
+ <require
+ permission="zope.Public"
+ interface=".interfaces.IPreferenceGroup
+ zope.interface.common.mapping.IEnumerableMapping" />
+ </class>
+
+ <!-- preference group roles -->
+ <adapter factory=".roles.PreferenceGroupRoles" />
+
+ <!-- preference group publisher -->
+ <adapter
+ for=".interfaces.IPreferenceGroup *"
+ factory="z3c.traverser.traverser.PluggableTraverser"
+ provides="zope.publisher.interfaces.IPublishTraverse" />
+
+ <subscriber
+ for=".interfaces.IPreferenceGroup *"
+ provides="z3c.traverser.interfaces.ITraverserPlugin"
+ factory=".publisher.PreferenceTraverserPlugin" />
+
+ <!-- predefined preference group -->
+ <z3ext:preferenceGroup
+ id="portal"
+ title="Portal preferences"
+ description="These are all the preferences related to common portal settings."
+ schema="z3ext.preferences.interfaces.IPortalPreferences" />
+
+ <z3ext:preferenceGroup
+ id="membership"
+ title="Membership preferences"
+ description="These are all the preferences related to portal membership."
+ schema=".interfaces.IMembershipPreferences" />
+
+ <!-- browser views -->
+ <include package=".browser" />
+
+ <!-- translations -->
+ <i18n:registerTranslations directory="locales"/>
+
+</configure>
Deleted: z3ext.preferences/tags/1.4.8/src/z3ext/preferences/interfaces.py
===================================================================
--- z3ext.preferences/trunk/src/z3ext/preferences/interfaces.py 2009-06-21 18:55:19 UTC (rev 101203)
+++ z3ext.preferences/tags/1.4.8/src/z3ext/preferences/interfaces.py 2009-06-22 05:43:56 UTC (rev 101205)
@@ -1,112 +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.preferences interfaces
-
-$Id$
-"""
-from zope import schema, interface
-from zope.configuration import fields
-from zope.location.interfaces import ILocation
-from zope.i18nmessageid import MessageFactory
-
-_ = MessageFactory('z3ext.preferences')
-
-ANNOTATION_KEY = 'zope.app.user.UserPreferences'
-
-
-class UnboundPreferenceGroup(Exception):
- """ Prefernce group is not bound to principal """
-
-
-class IPreferenceGroup(ILocation):
- """A group of preferences.
-
- This component represents a logical group of preferences. The preferences
- contained by this group is defined through the schema. The group has also
- a name by which it can be accessed.
-
- The fields specified in the schema *must* be available as attributes and
- items of the group instance. It is up to the implementation how this is
- realized, however, most often one will implement __setattr__ and
- __getattr__ as well as the common mapping API.
-
- The reason all the API fields are doubly underlined is to avoid name clashes.
- """
-
- __id__ = schema.TextLine(
- title = u"Id",
- description = u"The id of the group.",
- required = True)
-
- __schema__ = schema.InterfaceField(
- title = u"Schema",
- description = u"Schema describing the preferences of the group.",
- required = False,
- readonly = True)
-
- __title__ = fields.MessageID(
- title = u"Title",
- description = u"The title of the group used in the UI.",
- required = True)
-
- __description__ = fields.MessageID(
- title = u"Description",
- description = u"The description of the group used in the UI.",
- required = False)
-
- __principal__ = interface.Attribute('Owner principal of preferences')
- __permission__ = interface.Attribute('Set schema permission')
- __accesspermission__ = interface.Attribute('Access schema permission')
-
- def isAvailable():
- """ is group available for bound principal """
-
- def add(name):
- """ add subgroup name """
-
- def remove(name):
- """ remove subgroup name """
-
- def __bind__(principal=None, parent=None):
- """ bind preferences """
-
-
-class IPreferenceCategory(interface.Interface):
- """A collection of preference groups.
-
- Objects providing this interface serve as groups of preference
- groups. This allows UIs to distinguish between high- and low-level
- prefernce groups.
- """
-
-
-class IBound(interface.Interface):
- """ bound to context """
-
- __principal__ = interface.Attribute('IPrincipal object')
-
-
-class IRootPreferences(interface.Interface):
- """ root preferences """
-
- def __bind__(principal=None, parent=None):
- """ bind preferences """
-
-
-class IDataStorage(interface.Interface):
- """ data storage, set/get values as attributes """
-
-
-class IPortalPreferences(IPreferenceCategory):
- """ portal preferences """
Copied: z3ext.preferences/tags/1.4.8/src/z3ext/preferences/interfaces.py (from rev 101204, z3ext.preferences/trunk/src/z3ext/preferences/interfaces.py)
===================================================================
--- z3ext.preferences/tags/1.4.8/src/z3ext/preferences/interfaces.py (rev 0)
+++ z3ext.preferences/tags/1.4.8/src/z3ext/preferences/interfaces.py 2009-06-22 05:43:56 UTC (rev 101205)
@@ -0,0 +1,116 @@
+##############################################################################
+#
+# 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.preferences interfaces
+
+$Id$
+"""
+from zope import schema, interface
+from zope.configuration import fields
+from zope.location.interfaces import ILocation
+from zope.i18nmessageid import MessageFactory
+
+_ = MessageFactory('z3ext.preferences')
+
+ANNOTATION_KEY = 'zope.app.user.UserPreferences'
+
+
+class UnboundPreferenceGroup(Exception):
+ """ Prefernce group is not bound to principal """
+
+
+class IPreferenceGroup(ILocation):
+ """A group of preferences.
+
+ This component represents a logical group of preferences. The preferences
+ contained by this group is defined through the schema. The group has also
+ a name by which it can be accessed.
+
+ The fields specified in the schema *must* be available as attributes and
+ items of the group instance. It is up to the implementation how this is
+ realized, however, most often one will implement __setattr__ and
+ __getattr__ as well as the common mapping API.
+
+ The reason all the API fields are doubly underlined is to avoid name clashes.
+ """
+
+ __id__ = schema.TextLine(
+ title = u"Id",
+ description = u"The id of the group.",
+ required = True)
+
+ __schema__ = schema.InterfaceField(
+ title = u"Schema",
+ description = u"Schema describing the preferences of the group.",
+ required = False,
+ readonly = True)
+
+ __title__ = fields.MessageID(
+ title = u"Title",
+ description = u"The title of the group used in the UI.",
+ required = True)
+
+ __description__ = fields.MessageID(
+ title = u"Description",
+ description = u"The description of the group used in the UI.",
+ required = False)
+
+ __principal__ = interface.Attribute('Owner principal of preferences')
+ __permission__ = interface.Attribute('Set schema permission')
+ __accesspermission__ = interface.Attribute('Access schema permission')
+
+ def isAvailable():
+ """ is group available for bound principal """
+
+ def add(name):
+ """ add subgroup name """
+
+ def remove(name):
+ """ remove subgroup name """
+
+ def __bind__(principal=None, parent=None):
+ """ bind preferences """
+
+
+class IPreferenceCategory(interface.Interface):
+ """A collection of preference groups.
+
+ Objects providing this interface serve as groups of preference
+ groups. This allows UIs to distinguish between high- and low-level
+ prefernce groups.
+ """
+
+
+class IBound(interface.Interface):
+ """ bound to context """
+
+ __principal__ = interface.Attribute('IPrincipal object')
+
+
+class IRootPreferences(interface.Interface):
+ """ root preferences """
+
+ def __bind__(principal=None, parent=None):
+ """ bind preferences """
+
+
+class IDataStorage(interface.Interface):
+ """ data storage, set/get values as attributes """
+
+
+class IPortalPreferences(IPreferenceCategory):
+ """ portal preferences """
+
+
+class IMembershipPreferences(IPreferenceCategory):
+ """ membership principal preferences """
Deleted: z3ext.preferences/tags/1.4.8/src/z3ext/preferences/preferencetype.py
===================================================================
--- z3ext.preferences/trunk/src/z3ext/preferences/preferencetype.py 2009-06-21 18:55:19 UTC (rev 101203)
+++ z3ext.preferences/tags/1.4.8/src/z3ext/preferences/preferencetype.py 2009-06-22 05:43:56 UTC (rev 101205)
@@ -1,199 +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.
-#
-##############################################################################
-""" PreferenceGroup metaclass
-
-$Id$
-"""
-import sys
-from zope import interface
-from zope.schema import getFields
-from z3ext.preferences.interfaces import _
-from z3ext.preferences.preference import PreferenceGroup
-
-_marker = object()
-
-
-class PreferenceType(type):
- """ Metaclass for all preference groups
-
- >>> from zope import interface, schema
- >>> from z3ext.preferences import preferencetype
-
- >>> class IMyPreference(interface.Interface):
- ... title = schema.TextLine(title = u'Title')
-
- >>> class MyPreference(object):
- ... pass
-
- >>> PreferenceClass = preferencetype.PreferenceType(
- ... 'mypreference', IMyPreference, MyPreference, 'MyPreference', '')
-
- New class avilable by it's cname in z3ext.preferences.preferencetype module
-
- >>> getattr(preferencetype, 'Preference<mypreference>') is PreferenceClass
- True
-
- Automaticly generate schema fields to PreferenceProperty
-
- >>> PreferenceClass.title
- <z3ext.preferences.preferencetype.PreferenceProperty object at ...>
-
- >>> preference = PreferenceClass()
- >>> preference
- <z3ext.preferences.preferencetype.Preference<mypreference> object at ...>
-
- >>> isinstance(preference, MyPreference)
- True
-
- >>> isinstance(preference, preferencetype.PreferenceGroup)
- True
-
- We also can use number of base classes
-
- >>> class MyPreference2(object):
- ... pass
-
- >>> PreferenceClass = preferencetype.PreferenceType(
- ... 'mypreference', IMyPreference,
- ... (MyPreference, MyPreference2), 'MyPreference', '')
-
- """
-
- def __new__(cls, name, schema, class_=None, *args, **kw):
- cname = 'Preference<%s>'%name
- if type(class_) is tuple:
- bases = class_ + (PreferenceGroup,)
- elif class_ is not None:
- bases = (class_, PreferenceGroup)
- else:
- bases = (PreferenceGroup,)
-
- tp = type.__new__(cls, str(cname), bases, {})
- setattr(sys.modules['z3ext.preferences.preferencetype'], 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, PreferenceProperty(schema[f_id]))
-
- cls.__id__ = unicode(name)
- cls.__title__ = title
- cls.__description__ = description
- cls.__schema__ = DataProperty(schema)
- interface.classImplements(cls, 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 change __schema__")
-
-
-class PreferenceProperty(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'
-
- >>> from z3ext.preferences.storage import DataStorage
-
- Now we need content class
-
- >>> from z3ext.preferences.preferencetype import PreferenceProperty
- >>> class Content(object):
- ...
- ... attr1 = PreferenceProperty(field)
-
- Lets create class instance and add field values storage
-
- >>> ob = Content()
- >>> ob.data = DataStorage({}, None)
-
- 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')
-
- Remove attribute
-
- >>> del ob.attr1
-
- """
-
- 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 = getattr(inst.data, 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 hasattr(inst.data, self._name):
- raise ValueError(self._name, _(u'Field is readonly'))
- setattr(inst.data, self._name, value)
-
- def __delete__(self, inst):
- if hasattr(inst.data, self._name):
- delattr(inst.data, self._name)
Copied: z3ext.preferences/tags/1.4.8/src/z3ext/preferences/preferencetype.py (from rev 101204, z3ext.preferences/trunk/src/z3ext/preferences/preferencetype.py)
===================================================================
--- z3ext.preferences/tags/1.4.8/src/z3ext/preferences/preferencetype.py (rev 0)
+++ z3ext.preferences/tags/1.4.8/src/z3ext/preferences/preferencetype.py 2009-06-22 05:43:56 UTC (rev 101205)
@@ -0,0 +1,199 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+""" PreferenceGroup metaclass
+
+$Id$
+"""
+import sys
+from zope import interface
+from zope.schema import getFields
+from z3ext.preferences.interfaces import _
+from z3ext.preferences.preference import PreferenceGroup
+
+_marker = object()
+
+
+class PreferenceType(type):
+ """ Metaclass for all preference groups
+
+ >>> from zope import interface, schema
+ >>> from z3ext.preferences import preferencetype
+
+ >>> class IMyPreference(interface.Interface):
+ ... title = schema.TextLine(title = u'Title')
+
+ >>> class MyPreference(object):
+ ... pass
+
+ >>> PreferenceClass = preferencetype.PreferenceType(
+ ... 'mypreference', IMyPreference, MyPreference, 'MyPreference', '')
+
+ New class avilable by it's cname in z3ext.preferences.preferencetype module
+
+ >>> getattr(preferencetype, 'Preference<mypreference>') is PreferenceClass
+ True
+
+ Automaticly generate schema fields to PreferenceProperty
+
+ >>> PreferenceClass.title
+ <z3ext.preferences.preferencetype.PreferenceProperty object at ...>
+
+ >>> preference = PreferenceClass()
+ >>> preference
+ <z3ext.preferences.preferencetype.Preference<mypreference> object at ...>
+
+ >>> isinstance(preference, MyPreference)
+ True
+
+ >>> isinstance(preference, preferencetype.PreferenceGroup)
+ True
+
+ We also can use number of base classes
+
+ >>> class MyPreference2(object):
+ ... pass
+
+ >>> PreferenceClass = preferencetype.PreferenceType(
+ ... 'mypreference', IMyPreference,
+ ... (MyPreference, MyPreference2), 'MyPreference', '')
+
+ """
+
+ def __new__(cls, name, schema, class_=None, *args, **kw):
+ cname = 'Preference<%s>'%name
+ if type(class_) is tuple:
+ bases = class_ + (PreferenceGroup,)
+ elif class_ is not None:
+ bases = (class_, PreferenceGroup)
+ else:
+ bases = (PreferenceGroup,)
+
+ tp = type.__new__(cls, str(cname), bases, {})
+ setattr(sys.modules['z3ext.preferences.preferencetype'], 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, PreferenceProperty(schema[f_id]))
+
+ cls.__id__ = unicode(name)
+ cls.__title__ = title
+ cls.__description__ = description
+ cls.__schema__ = DataProperty(schema)
+ interface.classImplements(cls, 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 change __schema__")
+
+
+class PreferenceProperty(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'
+
+ >>> from z3ext.preferences.storage import DataStorage
+
+ Now we need content class
+
+ >>> from z3ext.preferences.preferencetype import PreferenceProperty
+ >>> class Content(object):
+ ...
+ ... attr1 = PreferenceProperty(field)
+
+ Lets create class instance and add field values storage
+
+ >>> ob = Content()
+ >>> ob.data = DataStorage({}, None)
+
+ 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')
+
+ Remove attribute
+
+ >>> del ob.attr1
+
+ """
+
+ 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 = getattr(inst.data, 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 hasattr(inst.data, self._name):
+ raise ValueError(self._name, _(u'Field is readonly'))
+ setattr(inst.data, self._name, value)
+
+ def __delete__(self, inst):
+ if hasattr(inst.data, self._name):
+ delattr(inst.data, self._name)
Deleted: z3ext.preferences/tags/1.4.8/src/z3ext/preferences/publisher.py
===================================================================
--- z3ext.preferences/trunk/src/z3ext/preferences/publisher.py 2009-06-21 18:55:19 UTC (rev 101203)
+++ z3ext.preferences/tags/1.4.8/src/z3ext/preferences/publisher.py 2009-06-22 05:43:56 UTC (rev 101205)
@@ -1,41 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2008 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""
-
-$Id$
-"""
-from zope import interface
-from zope.publisher.interfaces import NotFound
-from z3c.traverser.interfaces import ITraverserPlugin
-
-
-class PreferenceTraverserPlugin(object):
- """A traverser that knows how to look up objects by name in a container."""
- interface.implements(ITraverserPlugin)
-
- def __init__(self, container, request):
- self.context = container
- self.request = request
-
- def publishTraverse(self, request, name):
- """See zope.publisher.interfaces.IPublishTraverse"""
- try:
- subob = self.context.get(name, None)
- except:
- subob = None
-
- if subob is None:
- raise NotFound(self.context, name, request)
-
- return subob
Copied: z3ext.preferences/tags/1.4.8/src/z3ext/preferences/publisher.py (from rev 101204, z3ext.preferences/trunk/src/z3ext/preferences/publisher.py)
===================================================================
--- z3ext.preferences/tags/1.4.8/src/z3ext/preferences/publisher.py (rev 0)
+++ z3ext.preferences/tags/1.4.8/src/z3ext/preferences/publisher.py 2009-06-22 05:43:56 UTC (rev 101205)
@@ -0,0 +1,41 @@
+##############################################################################
+#
+# Copyright (c) 2008 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+
+$Id$
+"""
+from zope import interface
+from zope.publisher.interfaces import NotFound
+from z3c.traverser.interfaces import ITraverserPlugin
+
+
+class PreferenceTraverserPlugin(object):
+ """A traverser that knows how to look up objects by name in a container."""
+ interface.implements(ITraverserPlugin)
+
+ def __init__(self, container, request):
+ self.context = container
+ self.request = request
+
+ def publishTraverse(self, request, name):
+ """See zope.publisher.interfaces.IPublishTraverse"""
+ try:
+ subob = self.context.get(name, None)
+ except:
+ subob = None
+
+ if subob is None:
+ raise NotFound(self.context, name, request)
+
+ return subob
Deleted: z3ext.preferences/tags/1.4.8/src/z3ext/preferences/roles.py
===================================================================
--- z3ext.preferences/trunk/src/z3ext/preferences/roles.py 2009-06-21 18:55:19 UTC (rev 101203)
+++ z3ext.preferences/tags/1.4.8/src/z3ext/preferences/roles.py 2009-06-22 05:43:56 UTC (rev 101205)
@@ -1,52 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2008 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""
-
-$Id$
-"""
-from zope import interface, component
-from zope.app.security.settings import Allow, Unset
-from zope.securitypolicy.interfaces import IPrincipalRoleMap
-
-from interfaces import IBound
-
-
-class PreferenceGroupRoles(object):
- component.adapts(IBound)
- interface.implements(IPrincipalRoleMap)
-
- def __init__(self, context):
- self.pid = context.__principal__.id
-
- def getPrincipalsForRole(self, role_id):
- if (role_id == 'preference.Owner'):
- return ((self.pid, Allow),)
- else:
- return ()
-
- def getRolesForPrincipal(self, principal_id,
- allow = (('preference.Owner', Allow),)):
- if principal_id == self.pid:
- return allow
- else:
- return ()
-
- def getSetting(self, role_id, principal_id):
- if (principal_id == self.pid) and (role_id == 'preference.Owner'):
- return Allow
- else:
- return Unset
-
- def getPrincipalsAndRoles(self):
- return ()
Copied: z3ext.preferences/tags/1.4.8/src/z3ext/preferences/roles.py (from rev 101204, z3ext.preferences/trunk/src/z3ext/preferences/roles.py)
===================================================================
--- z3ext.preferences/tags/1.4.8/src/z3ext/preferences/roles.py (rev 0)
+++ z3ext.preferences/tags/1.4.8/src/z3ext/preferences/roles.py 2009-06-22 05:43:56 UTC (rev 101205)
@@ -0,0 +1,52 @@
+##############################################################################
+#
+# Copyright (c) 2008 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+
+$Id$
+"""
+from zope import interface, component
+from zope.app.security.settings import Allow, Unset
+from zope.securitypolicy.interfaces import IPrincipalRoleMap
+
+from interfaces import IBound
+
+
+class PreferenceGroupRoles(object):
+ component.adapts(IBound)
+ interface.implements(IPrincipalRoleMap)
+
+ def __init__(self, context):
+ self.pid = context.__principal__.id
+
+ def getPrincipalsForRole(self, role_id):
+ if (role_id == 'preference.Owner'):
+ return ((self.pid, Allow),)
+ else:
+ return ()
+
+ def getRolesForPrincipal(self, principal_id,
+ allow = (('preference.Owner', Allow),)):
+ if principal_id == self.pid:
+ return allow
+ else:
+ return ()
+
+ def getSetting(self, role_id, principal_id):
+ if (principal_id == self.pid) and (role_id == 'preference.Owner'):
+ return Allow
+ else:
+ return Unset
+
+ def getPrincipalsAndRoles(self):
+ return ()
Deleted: z3ext.preferences/tags/1.4.8/src/z3ext/preferences/tests/interfaces.py
===================================================================
--- z3ext.preferences/trunk/src/z3ext/preferences/tests/interfaces.py 2009-06-21 18:55:19 UTC (rev 101203)
+++ z3ext.preferences/tags/1.4.8/src/z3ext/preferences/tests/interfaces.py 2009-06-22 05:43:56 UTC (rev 101205)
@@ -1,56 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2008 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""
-
-$Id: 2007-12-12 12:27:02Z fafhrd $
-"""
-from zope import interface, schema
-
-
-class ICategory(interface.Interface):
-
- category = schema.TextLine(
- title = u'Category',
- required = False)
-
-
-class IPrefs1(interface.Interface):
-
- name = schema.TextLine(
- title = u'Name',
- required = True)
-
-
-class IPrefs2(interface.Interface):
-
- location = schema.TextLine(
- title = u'Location',
- default = u'',
- required = False)
-
-
-class IPrefs3(interface.Interface):
-
- location = schema.TextLine(
- title = u'Location',
- default = u'',
- required = False)
-
-
-class IPrefs4(interface.Interface):
-
- prefs4 = schema.TextLine(
- title = u'Prefs4',
- default = u'',
- required = False)
Copied: z3ext.preferences/tags/1.4.8/src/z3ext/preferences/tests/interfaces.py (from rev 101204, z3ext.preferences/trunk/src/z3ext/preferences/tests/interfaces.py)
===================================================================
--- z3ext.preferences/tags/1.4.8/src/z3ext/preferences/tests/interfaces.py (rev 0)
+++ z3ext.preferences/tags/1.4.8/src/z3ext/preferences/tests/interfaces.py 2009-06-22 05:43:56 UTC (rev 101205)
@@ -0,0 +1,56 @@
+##############################################################################
+#
+# Copyright (c) 2008 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+
+$Id: 2007-12-12 12:27:02Z fafhrd $
+"""
+from zope import interface, schema
+
+
+class ICategory(interface.Interface):
+
+ category = schema.TextLine(
+ title = u'Category',
+ required = False)
+
+
+class IPrefs1(interface.Interface):
+
+ name = schema.TextLine(
+ title = u'Name',
+ required = True)
+
+
+class IPrefs2(interface.Interface):
+
+ location = schema.TextLine(
+ title = u'Location',
+ default = u'',
+ required = False)
+
+
+class IPrefs3(interface.Interface):
+
+ location = schema.TextLine(
+ title = u'Location',
+ default = u'',
+ required = False)
+
+
+class IPrefs4(interface.Interface):
+
+ prefs4 = schema.TextLine(
+ title = u'Prefs4',
+ default = u'',
+ required = False)
Deleted: z3ext.preferences/tags/1.4.8/src/z3ext/preferences/zcml.py
===================================================================
--- z3ext.preferences/trunk/src/z3ext/preferences/zcml.py 2009-06-21 18:55:19 UTC (rev 101203)
+++ z3ext.preferences/tags/1.4.8/src/z3ext/preferences/zcml.py 2009-06-22 05:43:56 UTC (rev 101205)
@@ -1,266 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2008 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-""" z3ext:preferenceGroup directive implementation
-
-$Id$
-"""
-from zope import interface
-from zope.schema import Int
-from zope.component import getUtility, queryUtility, getGlobalSiteManager
-from zope.schema.interfaces import IField
-from zope.location.interfaces import ILocation
-
-from zope.security.zcml import Permission
-from zope.security.checker import Checker, CheckerPublic
-from zope.security.interfaces import IPrincipal
-
-from zope.interface.common.mapping import IEnumerableMapping
-
-from zope.component.zcml import utility, adapter
-from zope.component.interface import provideInterface
-
-from zope.configuration import fields
-from zope.configuration.exceptions import ConfigurationError
-
-from zope.app.security.protectclass import \
- protectName, protectSetAttribute, protectLikeUnto
-
-from preference import PreferenceGroup
-from interfaces import IPreferenceGroup
-from preferencetype import PreferenceType
-from utils import PrincipalChecker, PermissionChecker
-
-
-class IPreferenceGroupDirective(interface.Interface):
- """Register a preference group."""
-
- id = fields.PythonIdentifier(
- title=u"Id",
- description=u"""
- Id of the preference group used to access the group. The id should
- be a valid path in the preferences tree.""",
- required=True)
-
- for_ = fields.GlobalInterface(
- title=u"For",
- description=u"Principal interface to use this preference for.",
- required=False)
-
- schema = fields.GlobalInterface(
- title=u"Schema",
- description=u"Schema of the preference group used defining the "
- u"preferences of the group.",
- required=True)
-
- title = fields.MessageID(
- title=u"Title",
- description=u"Title of the preference group used in UIs.",
- required=True)
-
- description = fields.MessageID(
- title=u"Description",
- description=u"Description of the preference group used in UIs.",
- required=False)
-
- class_ = fields.GlobalObject(
- title=u"Class",
- description=u"Custom IPreferenceGroup implementation.",
- required=False)
-
- provides = fields.Tokens(
- title = u'Provides',
- required = False,
- value_type = fields.GlobalInterface())
-
- permission = Permission(
- title = u'Permission',
- description = u'Default set schema permission.',
- required = False)
-
- accesspermission = Permission(
- title = u'Access permission',
- description = u'Default access permission.',
- required = False)
-
- tests = fields.Tokens(
- title = u"Tests",
- description = u'Tests for check availability.',
- value_type = fields.GlobalObject(),
- required = False)
-
- order = Int(
- title = u'Order',
- default = 999999,
- required = False)
-
-
-class PreferenceGroupAdapter(object):
-
- def __init__(self, name):
- self.name = name
-
- def __call__(self, principal, context=None):
- prefs = getUtility(IPreferenceGroup, self.name)
- return prefs.__bind__(principal, context)
-
-
-class PreferenceGroupDirective(object):
-
- def __init__(self, _context, id, schema, title,
- for_=None, description=u'', class_=None, provides=[],
- permission='z3ext.ModifyPreference', accesspermission='',
- tests=(), order = 9999):
-
- if not accesspermission:
- accesspermission = permission
-
- if permission == 'zope.Public':
- permission = CheckerPublic
-
- if accesspermission == 'zope.Public':
- accesspermission = CheckerPublic
-
- Class = PreferenceType(str(id), schema, class_, title, description)
- Class.order = order
- Class.__permission__ = permission
- Class.__accesspermission__ = accesspermission
-
- tests = tuple(tests)
- if permission != CheckerPublic:
- tests = tests + (PermissionChecker,)
- if interface.interfaces.IInterface.providedBy(for_):
- tests = tests + (PrincipalChecker(for_),)
-
- group = Class(tests)
-
- utility(_context, IPreferenceGroup, group, name=id)
- adapter(_context, (PreferenceGroupAdapter(id),), schema,
- (for_ or IPrincipal,))
- adapter(_context, (PreferenceGroupAdapter(id),), schema,
- (for_ or IPrincipal, interface.Interface))
-
- interface.classImplements(Class, *provides)
-
- self._class = Class
- self._context = _context
- self._permission = permission
-
- self.require(_context, permission, set_schema=(schema,))
- self.require(_context, accesspermission,
- interface=(IPreferenceGroup, schema))
-
- self.require(_context, CheckerPublic,
- interface=(IEnumerableMapping, ILocation),
- attributes=('isAvailable',
- '__id__', '__schema__',
- '__title__', '__description__',
- '__permission__'))
-
- schema.setTaggedValue('preferenceID', id)
-
- _context.action(
- discriminator=('z3ext:preferences', schema),
- callable=addSubgroup, args=(group,))
-
- def require(self, _context,
- permission=None, attributes=None, interface=None,
- set_attributes=None, set_schema=None):
- """Require a permission to access a specific aspect"""
- if not (interface or attributes or set_attributes or set_schema):
- raise ConfigurationError("Nothing required")
-
- if not permission:
- raise ConfigurationError("No permission specified")
-
- if interface:
- for i in interface:
- if i:
- self.__protectByInterface(i, permission)
-
- if attributes:
- self.__protectNames(attributes, permission)
-
- if set_attributes:
- self.__protectSetAttributes(set_attributes, permission)
-
- if set_schema:
- for s in set_schema:
- self.__protectSetSchema(s, permission)
-
- def allow(self, _context, attributes=None, interface=None):
- """Like require, but with permission_id zope.Public"""
- return self.require(_context, self._permission, attributes, interface)
-
- def __protectByInterface(self, interface, permission_id):
- "Set a permission on names in an interface."
- for n, d in interface.namesAndDescriptions(1):
- self.__protectName(n, permission_id)
-
- self._context.action(
- discriminator = None,
- callable = provideInterface,
- args = (interface.__module__+'.'+interface.getName(), interface))
-
- def __protectName(self, name, permission_id):
- "Set a permission on a particular name."
- self._context.action(
- discriminator = ('z3ext:preferences:protectName', object()),
- callable = protectName,
- args = (self._class, name, permission_id))
-
- def __protectNames(self, names, permission_id):
- "Set a permission on a bunch of names."
- for name in names:
- self.__protectName(name, permission_id)
-
- def __protectSetAttributes(self, names, permission_id):
- "Set a permission on a bunch of names."
- for name in names:
- self._context.action(
- discriminator = (
- 'z3ext:preferences:protectSetAttribute', object()),
- callable = protectSetAttribute,
- args = (self._class, name, permission_id))
-
- def __protectSetSchema(self, schema, permission_id):
- "Set a permission on a bunch of names."
- _context = self._context
-
- for name in schema:
- field = schema[name]
- if IField.providedBy(field) and not field.readonly:
- _context.action(
- discriminator = (
- 'z3ext:preferences:protectSetAttribute', object()),
- callable = protectSetAttribute,
- args = (self._class, name, permission_id))
-
- _context.action(
- discriminator = None,
- callable = provideInterface,
- args = (schema.__module__+'.'+schema.getName(), schema))
-
-
-def addSubgroup(group):
- if '.' in group.__id__:
- parentId = group.__id__.split('.')[0]
- else:
- parentId = ''
-
- parent = queryUtility(IPreferenceGroup, parentId)
- if parent is None:
- parent = getGlobalSiteManager().getUtility(IPreferenceGroup, parentId)
-
- parent.add(group.__name__)
- group.__parent__ = parent
Copied: z3ext.preferences/tags/1.4.8/src/z3ext/preferences/zcml.py (from rev 101204, z3ext.preferences/trunk/src/z3ext/preferences/zcml.py)
===================================================================
--- z3ext.preferences/tags/1.4.8/src/z3ext/preferences/zcml.py (rev 0)
+++ z3ext.preferences/tags/1.4.8/src/z3ext/preferences/zcml.py 2009-06-22 05:43:56 UTC (rev 101205)
@@ -0,0 +1,266 @@
+##############################################################################
+#
+# Copyright (c) 2008 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+""" z3ext:preferenceGroup directive implementation
+
+$Id$
+"""
+from zope import interface
+from zope.schema import Int
+from zope.component import getUtility, queryUtility, getGlobalSiteManager
+from zope.schema.interfaces import IField
+from zope.location.interfaces import ILocation
+
+from zope.security.zcml import Permission
+from zope.security.checker import Checker, CheckerPublic
+from zope.security.interfaces import IPrincipal
+
+from zope.interface.common.mapping import IEnumerableMapping
+
+from zope.component.zcml import utility, adapter
+from zope.component.interface import provideInterface
+
+from zope.configuration import fields
+from zope.configuration.exceptions import ConfigurationError
+
+from zope.app.security.protectclass import \
+ protectName, protectSetAttribute, protectLikeUnto
+
+from preference import PreferenceGroup
+from interfaces import IPreferenceGroup
+from preferencetype import PreferenceType
+from utils import PrincipalChecker, PermissionChecker
+
+
+class IPreferenceGroupDirective(interface.Interface):
+ """Register a preference group."""
+
+ id = fields.PythonIdentifier(
+ title=u"Id",
+ description=u"""
+ Id of the preference group used to access the group. The id should
+ be a valid path in the preferences tree.""",
+ required=True)
+
+ for_ = fields.GlobalInterface(
+ title=u"For",
+ description=u"Principal interface to use this preference for.",
+ required=False)
+
+ schema = fields.GlobalInterface(
+ title=u"Schema",
+ description=u"Schema of the preference group used defining the "
+ u"preferences of the group.",
+ required=True)
+
+ title = fields.MessageID(
+ title=u"Title",
+ description=u"Title of the preference group used in UIs.",
+ required=True)
+
+ description = fields.MessageID(
+ title=u"Description",
+ description=u"Description of the preference group used in UIs.",
+ required=False)
+
+ class_ = fields.GlobalObject(
+ title=u"Class",
+ description=u"Custom IPreferenceGroup implementation.",
+ required=False)
+
+ provides = fields.Tokens(
+ title = u'Provides',
+ required = False,
+ value_type = fields.GlobalInterface())
+
+ permission = Permission(
+ title = u'Permission',
+ description = u'Default set schema permission.',
+ required = False)
+
+ accesspermission = Permission(
+ title = u'Access permission',
+ description = u'Default access permission.',
+ required = False)
+
+ tests = fields.Tokens(
+ title = u"Tests",
+ description = u'Tests for check availability.',
+ value_type = fields.GlobalObject(),
+ required = False)
+
+ order = Int(
+ title = u'Order',
+ default = 999999,
+ required = False)
+
+
+class PreferenceGroupAdapter(object):
+
+ def __init__(self, name):
+ self.name = name
+
+ def __call__(self, principal, context=None):
+ prefs = getUtility(IPreferenceGroup, self.name)
+ return prefs.__bind__(principal, context)
+
+
+class PreferenceGroupDirective(object):
+
+ def __init__(self, _context, id, schema, title,
+ for_=None, description=u'', class_=None, provides=[],
+ permission='z3ext.ModifyPreference', accesspermission='',
+ tests=(), order = 9999):
+
+ if not accesspermission:
+ accesspermission = permission
+
+ if permission == 'zope.Public':
+ permission = CheckerPublic
+
+ if accesspermission == 'zope.Public':
+ accesspermission = CheckerPublic
+
+ Class = PreferenceType(str(id), schema, class_, title, description)
+ Class.order = order
+ Class.__permission__ = permission
+ Class.__accesspermission__ = accesspermission
+
+ tests = tuple(tests)
+ if permission != CheckerPublic:
+ tests = tests + (PermissionChecker,)
+ if interface.interfaces.IInterface.providedBy(for_):
+ tests = tests + (PrincipalChecker(for_),)
+
+ group = Class(tests)
+
+ utility(_context, IPreferenceGroup, group, name=id)
+ adapter(_context, (PreferenceGroupAdapter(id),), schema,
+ (for_ or IPrincipal,))
+ adapter(_context, (PreferenceGroupAdapter(id),), schema,
+ (for_ or IPrincipal, interface.Interface))
+
+ interface.classImplements(Class, *provides)
+
+ self._class = Class
+ self._context = _context
+ self._permission = permission
+
+ self.require(_context, permission, set_schema=(schema,))
+ self.require(_context, accesspermission,
+ interface=(IPreferenceGroup, schema))
+
+ self.require(_context, CheckerPublic,
+ interface=(IEnumerableMapping, ILocation),
+ attributes=('isAvailable',
+ '__id__', '__schema__',
+ '__title__', '__description__',
+ '__permission__'))
+
+ schema.setTaggedValue('preferenceID', id)
+
+ _context.action(
+ discriminator=('z3ext:preferences', schema),
+ callable=addSubgroup, args=(group,))
+
+ def require(self, _context,
+ permission=None, attributes=None, interface=None,
+ set_attributes=None, set_schema=None):
+ """Require a permission to access a specific aspect"""
+ if not (interface or attributes or set_attributes or set_schema):
+ raise ConfigurationError("Nothing required")
+
+ if not permission:
+ raise ConfigurationError("No permission specified")
+
+ if interface:
+ for i in interface:
+ if i:
+ self.__protectByInterface(i, permission)
+
+ if attributes:
+ self.__protectNames(attributes, permission)
+
+ if set_attributes:
+ self.__protectSetAttributes(set_attributes, permission)
+
+ if set_schema:
+ for s in set_schema:
+ self.__protectSetSchema(s, permission)
+
+ def allow(self, _context, attributes=None, interface=None):
+ """Like require, but with permission_id zope.Public"""
+ return self.require(_context, self._permission, attributes, interface)
+
+ def __protectByInterface(self, interface, permission_id):
+ "Set a permission on names in an interface."
+ for n, d in interface.namesAndDescriptions(1):
+ self.__protectName(n, permission_id)
+
+ self._context.action(
+ discriminator = None,
+ callable = provideInterface,
+ args = (interface.__module__+'.'+interface.getName(), interface))
+
+ def __protectName(self, name, permission_id):
+ "Set a permission on a particular name."
+ self._context.action(
+ discriminator = ('z3ext:preferences:protectName', object()),
+ callable = protectName,
+ args = (self._class, name, permission_id))
+
+ def __protectNames(self, names, permission_id):
+ "Set a permission on a bunch of names."
+ for name in names:
+ self.__protectName(name, permission_id)
+
+ def __protectSetAttributes(self, names, permission_id):
+ "Set a permission on a bunch of names."
+ for name in names:
+ self._context.action(
+ discriminator = (
+ 'z3ext:preferences:protectSetAttribute', object()),
+ callable = protectSetAttribute,
+ args = (self._class, name, permission_id))
+
+ def __protectSetSchema(self, schema, permission_id):
+ "Set a permission on a bunch of names."
+ _context = self._context
+
+ for name in schema:
+ field = schema[name]
+ if IField.providedBy(field) and not field.readonly:
+ _context.action(
+ discriminator = (
+ 'z3ext:preferences:protectSetAttribute', object()),
+ callable = protectSetAttribute,
+ args = (self._class, name, permission_id))
+
+ _context.action(
+ discriminator = None,
+ callable = provideInterface,
+ args = (schema.__module__+'.'+schema.getName(), schema))
+
+
+def addSubgroup(group):
+ if '.' in group.__id__:
+ parentId = group.__id__.split('.')[0]
+ else:
+ parentId = ''
+
+ parent = queryUtility(IPreferenceGroup, parentId)
+ if parent is None:
+ parent = getGlobalSiteManager().getUtility(IPreferenceGroup, parentId)
+
+ parent.add(group.__name__)
+ group.__parent__ = parent
More information about the Checkins
mailing list