[Zope-CMF] [dev] CMFSetup: proposal for improving handlers
yuppie
y.2004_ at wcm-solutions.de
Fri Dec 10 09:25:39 EST 2004
Hi!
It should become easier to maintain existing setup handlers and to write
new ones. This is a proposal for simplifying handlers and adding a new
one for site properties.
simplifying handlers:
---------------------
The setup handlers contain a lot of redundant code. I propose to add a
ConfiguratorBase class in utils that does most of the work currently
done in each Configurator and in related helper methods.
A subclass of ConfiguratorBase just needs 3 methods:
- _getExportTemplate:
Returns the Page Template.
- listToolInfo or something similar:
Returns the data needed by the Page Template. No changes proposed.
- _getImportMapping:
Returns a mapping that contains rules for importing nodes.
Here is an example for a _getImportMapping method that would replace
_extractActionProviderNodes, _extractActionNodes and
_extractPermissionNodes in
http://cvs.zope.org/CMF/CMFSetup/actions.py?rev=1.15&content-type=text/vnd.viewcvs-markup
:
def _getImportMapping(self):
return {
'actions-tool':
{ 'action-provider': {_KEY: 'providers'},
'object': {_KEY: 'objects', _DEFAULT: ()} },
'action-provider':
{ 'id': {},
'action': {_KEY: 'actions', _DEFAULT: ()} },
'action':
{ 'action_id': {_KEY: 'id'},
'title': {},
'description': {_CONVERTER: self._convertToUnique},
'category': {},
'condition_expr': {_KEY: 'condition'},
'permission': {_KEY: 'permissions', _DEFAULT: ()},
'category': {},
'visible': {_CONVERTER: self._convertToBoolean},
'url_expr': {_KEY: 'action'} },
'permission':
{ '#text': {_KEY: None} } }
_KEY: If specified, that key is used in the resulting dict instead of
the subnode/attribute name. If None, the value of a single
subnode/attribute is returned instead of the dict.
_DEFAULT: Makes sure a default value is returned. This can be a
formatted string, using values of other node attributes.
_CONVERTER: Modifies the value. If necessary the Configurator can have
its own converters.
new handler for site properties:
--------------------------------
I have some code for importing/exporting properties. That code could
become part of ConfiguratorBase.
Here is an example export:
<?xml version="1.0"?>
<site>
<property name="title">Portal</property>
<property name="description"></property>
<property name="email_from_address"
type="string">postmaster at localhost</property>
<property name="email_from_name" type="string">Portal
Administrator</property>
<property name="validate_email" type="boolean"></property>
<property name="default_charset" type="string"></property>
</site>
Does it make sense to have one handler just for site properties, called
something like "Products.CMFSetup.properties.importSiteProperties"?
Or should there better be one config file for all global settings that
are not tool settings? Something like
"Products.CMFSetup.globals.importGlobalSettings"?
Any questions, comments or objections?
I'd like to make the proposed changes in 1.5 branch and HEAD. I would
convert all setup handlers besides the workflow handlers to the new
style. The workflow handlers contain 50% of the existing handler code
and they work as they are, so there is no need to waste time converting
them.
Cheers,
Yuppie
More information about the Zope-CMF
mailing list