[CMF-checkins] CVS: CMF/CMFSetup - actions.py:1.5
Tres Seaver
tseaver at zope.com
Sat May 29 21:44:38 EDT 2004
Update of /cvs-repository/CMF/CMFSetup
In directory cvs.zope.org:/tmp/cvs-serv25614
Modified Files:
actions.py
Log Message:
- Refactoring: *Don't* modify while parsing!
=== CMF/CMFSetup/actions.py 1.4 => 1.5 ===
--- CMF/CMFSetup/actions.py:1.4 Tue May 25 08:48:53 2004
+++ CMF/CMFSetup/actions.py Sat May 29 21:44:37 2004
@@ -24,9 +24,12 @@
class _ActionProviderParser( HandlerBase ):
- def __init__( self, site, encoding ):
+ security = ClassSecurityInfo()
+ security.declareObjectPrivate()
+ security.setDefaultAccess( 'deny' )
+
+ def __init__( self, encoding ):
- self._site = site
self._encoding = encoding
self._provider_info = {}
self._provider_ids = []
@@ -63,34 +66,8 @@
else:
raise ValueError, 'Unknown element %s' % name
- def endElement( self, name ):
-
- if name in ( 'actions-tool', 'action' ):
- pass
-
- def endDocument( self ):
-
- actions_tool = getToolByName( self._site, 'portal_actions' )
-
- for provider_id in self._provider_ids:
-
- if provider_id not in actions_tool.listActionProviders():
-
- actions_tool.addActionProvider( provider_id )
-
- provider = getToolByName( self._site, provider_id )
- provider._actions = ()
-
- for info in self._provider_info.get( provider_id, () ):
- provider.addAction( id=info[ 'action_id' ]
- , name=info[ 'name' ]
- , action=info[ 'action' ]
- , condition=info[ 'condition' ]
- , permission=info[ 'permission' ]
- , category=info[ 'category' ]
- , visible=info[ 'visible' ]
- )
+InitializeClass( _ActionProviderParser )
class ActionProvidersConfigurator( Implicit ):
@@ -165,7 +142,30 @@
if reader is not None:
text = reader()
- parseString( text, _ActionProviderParser( self._site, encoding ) )
+ parser = _ActionProviderParser( encoding )
+ parseString( text, parser )
+
+ actions_tool = getToolByName( self._site, 'portal_actions' )
+
+ for provider_id in parser._provider_ids:
+
+ if provider_id not in actions_tool.listActionProviders():
+
+ actions_tool.addActionProvider( provider_id )
+
+ provider = getToolByName( self._site, provider_id )
+ provider._actions = ()
+
+ for info in parser._provider_info.get( provider_id, () ):
+
+ provider.addAction( id=info[ 'action_id' ]
+ , name=info[ 'name' ]
+ , action=info[ 'action' ]
+ , condition=info[ 'condition' ]
+ , permission=info[ 'permission' ]
+ , category=info[ 'category' ]
+ , visible=info[ 'visible' ]
+ )
InitializeClass( ActionProvidersConfigurator )
More information about the CMF-checkins
mailing list