[Checkins] SVN: Products.GenericSetup/trunk/Products/GenericSetup/
Added default values to the registerProfile ZCML directive.
None of the attributes is required anymore. As a name
'default' is used unless specified otherwise,
title is autogenerated and description is optional,
as the one from metadata.xml will be used anyways. Most often people
used these defaultsanyways,
so we can spare them to write those down.
Hanno Schlichting
plone at hannosch.info
Thu Jan 17 16:55:33 EST 2008
Log message for revision 82937:
Added default values to the registerProfile ZCML directive. None of the attributes is required anymore. As a name 'default' is used unless specified otherwise, title is autogenerated and description is optional, as the one from metadata.xml will be used anyways. Most often people used these defaultsanyways, so we can spare them to write those down.
Changed:
U Products.GenericSetup/trunk/Products/GenericSetup/CHANGES.txt
U Products.GenericSetup/trunk/Products/GenericSetup/tests/test_zcml.py
U Products.GenericSetup/trunk/Products/GenericSetup/zcml.py
-=-
Modified: Products.GenericSetup/trunk/Products/GenericSetup/CHANGES.txt
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/CHANGES.txt 2008-01-17 17:45:35 UTC (rev 82936)
+++ Products.GenericSetup/trunk/Products/GenericSetup/CHANGES.txt 2008-01-17 21:55:32 UTC (rev 82937)
@@ -2,6 +2,8 @@
GenericSetup 1.4.0 (unreleased)
+ - Added default values to the registerProfile ZCML directive.
+
- Add a ZMI interface to find and remove invalid steps from the
persistent registries.
Modified: Products.GenericSetup/trunk/Products/GenericSetup/tests/test_zcml.py
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/tests/test_zcml.py 2008-01-17 17:45:35 UTC (rev 82936)
+++ Products.GenericSetup/trunk/Products/GenericSetup/tests/test_zcml.py 2008-01-17 21:55:32 UTC (rev 82937)
@@ -40,6 +40,56 @@
def c_dummy_upgrade_handler(context):
pass
+def test_simpleRegisterProfile():
+ """
+ Use the genericsetup:registerProfile directive::
+
+ >>> import Products.GenericSetup
+ >>> from Products.Five import zcml
+ >>> configure_zcml = '''
+ ... <configure
+ ... xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
+ ... i18n_domain="foo">
+ ... <genericsetup:registerProfile
+ ... provides="Products.GenericSetup.interfaces.EXTENSION"
+ ... />
+ ... </configure>'''
+ >>> zcml.load_config('meta.zcml', Products.GenericSetup)
+ >>> zcml.load_string(configure_zcml)
+
+ Make sure the profile is registered correctly::
+
+ >>> from Products.GenericSetup.registry import _profile_registry
+ >>> profile_id = 'Products.GenericSetup:default'
+ >>> profile_id in _profile_registry._profile_ids
+ True
+ >>> info = _profile_registry._profile_info[profile_id]
+ >>> info['id']
+ u'Products.GenericSetup:default'
+ >>> info['title']
+ u"Profile 'default' from 'Products.GenericSetup'"
+ >>> info['description']
+ u''
+ >>> info['path']
+ u'profiles/default'
+ >>> info['product']
+ 'Products.GenericSetup'
+ >>> from Products.GenericSetup.interfaces import EXTENSION
+ >>> info['type'] is EXTENSION
+ True
+ >>> info['for'] is None
+ True
+
+ Clean up and make sure the cleanup works::
+
+ >>> from zope.testing.cleanup import cleanUp
+ >>> cleanUp()
+ >>> profile_id in _profile_registry._profile_ids
+ False
+ >>> profile_id in _profile_registry._profile_info
+ False
+ """
+
def test_registerProfile():
"""
Use the genericsetup:registerProfile directive::
Modified: Products.GenericSetup/trunk/Products/GenericSetup/zcml.py
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/zcml.py 2008-01-17 17:45:35 UTC (rev 82936)
+++ Products.GenericSetup/trunk/Products/GenericSetup/zcml.py 2008-01-17 21:55:32 UTC (rev 82937)
@@ -36,18 +36,21 @@
name = PythonIdentifier(
title=u'Name',
- description=u'',
- required=True)
+ description=u"If not specified 'default' is used.",
+ default=u'default',
+ required=False)
title = MessageID(
title=u'Title',
- description=u'',
- required=True)
+ description=u'Optional title for the profile.',
+ default=None,
+ required=False)
description = MessageID(
title=u'Description',
- description=u'',
- required=True)
+ description=u'Optional description for the profile.',
+ default=None,
+ required=False)
directory = Path(
title=u'Path',
@@ -68,14 +71,20 @@
_profile_regs = []
-def registerProfile(_context, name, title, description, directory=None,
- provides=BASE, for_=None):
+def registerProfile(_context, name=u'default', title=None, description=None,
+ directory=None, provides=BASE, for_=None):
""" Add a new profile to the registry.
"""
product = _context.package.__name__
if directory is None:
directory = 'profiles/%s' % name
+ if title is None:
+ title = u"Profile '%s' from '%s'" % (name, product)
+
+ if description is None:
+ description = u''
+
_profile_regs.append('%s:%s' % (product, name))
_context.action(
More information about the Checkins
mailing list