[CMF-checkins] CVS: CMF/CMFSetup - actions.py:1.18

Yvo Schubbe y.2005- at wcm-solutions.de
Tue Jan 25 14:50:12 EST 2005


Update of /cvs-repository/CMF/CMFSetup
In directory cvs.zope.org:/tmp/cvs-serv24836/CMFSetup

Modified Files:
	actions.py 
Log Message:
merged yuppie-new_actions-branch:
- added ActionCategory and Action interfaces
- added ActionCategory and Action classes
- modified ActionsTool to make use of these new classes
- removed deprecated 'name' and 'permissions' keys from ActionInfo
- allowed 'description' key in ActionInfo
- implemented IAction in the oldstyle ActionInformation class and used this interface to simplify ActionInfo
- updated setup handlers, tests, default profile and skins
- fixed ActionInfo issue regarding permissions in oldstyle action dicts


=== CMF/CMFSetup/actions.py 1.17 => 1.18 ===
--- CMF/CMFSetup/actions.py:1.17	Wed Jan 12 05:57:14 2005
+++ CMF/CMFSetup/actions.py	Tue Jan 25 14:49:42 2005
@@ -19,7 +19,6 @@
 from Globals import InitializeClass
 from Products.PageTemplates.PageTemplateFile import PageTemplateFile
 
-from Products.CMFCore.ActionInformation import ActionInformation
 from Products.CMFCore.ActionProviderBase import IActionProvider
 from Products.CMFCore.utils import getToolByName
 
@@ -33,6 +32,7 @@
 #   Configurator entry points
 #
 _FILENAME = 'actions.xml'
+_SPECIAL_PROVIDERS = ('portal_actions', 'portal_types', 'portal_workflow')
 
 def importActionProviders( context ):
 
@@ -72,6 +72,9 @@
         for provider_id in actions_tool.listActionProviders():
             actions_tool.deleteActionProvider( provider_id )
 
+        for obj_id in actions_tool.objectIds():
+            actions_tool._delObject(obj_id)
+
     text = context.readDataFile( _FILENAME )
 
     if text is not None:
@@ -81,13 +84,53 @@
 
         for p_info in tool_info[ 'providers' ]:
 
-            if p_info[ 'id' ] not in actions_tool.listActionProviders():
+            if p_info[ 'id' ] in _SPECIAL_PROVIDERS and \
+                    p_info[ 'id' ] not in actions_tool.listActionProviders():
 
                 actions_tool.addActionProvider( p_info[ 'id' ] )
 
             provider = getToolByName( site, p_info[ 'id' ] )
-            provider._actions = [ ActionInformation(**a_info)
-                                  for a_info in p_info[ 'actions' ] ]
+            provider._actions = ()
+
+            if p_info['actions']:
+                for a_info in p_info['actions']:
+                    parent = actions_tool
+                    for category_id in a_info['category'].split('/'):
+                        if category_id not in parent.objectIds():
+                            o_info = {'id': str(category_id),
+                                      'meta_type': 'CMF Action Category',
+                                      'properties':(),
+                                      'objects': ()}
+                            apc.initObject(parent, o_info)
+                        parent = parent._getOb(category_id)
+                    if a_info['id'] not in parent.objectIds():
+                        o_info = {'id': str(a_info['id']),
+                                  'meta_type': 'CMF Action',
+                                  'properties':
+                                     ( {'id': 'title',
+                                        'value': a_info.get('title', ''),
+                                        'elements': ()}
+                                     , {'id': 'description',
+                                        'value': a_info.get('description', ''),
+                                        'elements': ()}
+                                     , {'id': 'url_expr',
+                                        'value': a_info.get('action', ''),
+                                        'elements': ()}
+                                     , {'id': 'available_expr',
+                                        'value': a_info.get('condition', ''),
+                                        'elements': ()}
+                                     , {'id': 'permissions',
+                                        'value': '',
+                                        'elements': a_info['permissions']}
+                                     , {'id': 'visible',
+                                        'value': a_info.get('visible', True),
+                                        'elements': ()}
+                                     ),
+                                  'objects': ()}
+                        apc.initObject(parent, o_info)
+
+    for sub_info in tool_info[ 'objects' ]:
+        apc.initObject( actions_tool, sub_info )
 
     return 'Action providers imported.'
 
@@ -149,7 +192,10 @@
             if not IActionProvider.isImplementedBy( provider ):
                 continue
 
-            actions = provider.listActions()
+            if provider_id == 'portal_actions':
+                actions = provider._actions
+            else:
+                actions = provider.listActions()
 
             if actions and isinstance(actions[0], dict):
                 continue
@@ -158,6 +204,13 @@
 
         return result
 
+    security.declareProtected(ManagePortal, 'listSubobjectInfos')
+    def listSubobjectInfos(self):
+        """ List info mappings for the objects stored inside the tool.
+        """
+        atool = getToolByName(self._site, 'portal_actions')
+        return [ self._extractObject(obj) for obj in atool.objectValues() ]
+
     def _getExportTemplate(self):
 
         return PageTemplateFile('apcExport.xml', _xmldir)
@@ -166,7 +219,8 @@
 
         return {
           'actions-tool':
-             { 'action-provider': {KEY: 'providers'} },
+             { 'action-provider': {KEY: 'providers'},
+               'object':          {KEY: 'objects', DEFAULT: ()} },
           'action-provider':
              { 'id':              {},
                'action':          {KEY: 'actions', DEFAULT: ()} },



More information about the CMF-checkins mailing list