[CMF-checkins] SVN: CMF/branches/1.6/CMFCore/exportimport/actions.py * purge the auto-created actions in the action providers and support

Rob Miller ra at burningman.com
Sat Nov 19 15:09:26 EST 2005


Log message for revision 40254:
  * purge the auto-created actions in the action providers and support
    old-style action creation
  
  

Changed:
  U   CMF/branches/1.6/CMFCore/exportimport/actions.py

-=-
Modified: CMF/branches/1.6/CMFCore/exportimport/actions.py
===================================================================
--- CMF/branches/1.6/CMFCore/exportimport/actions.py	2005-11-19 20:08:09 UTC (rev 40253)
+++ CMF/branches/1.6/CMFCore/exportimport/actions.py	2005-11-19 20:09:26 UTC (rev 40254)
@@ -173,3 +173,45 @@
 
             if provider_id not in self.context.listActionProviders():
                 self.context.addActionProvider(provider_id)
+                # delete any actions that are auto-created
+                provider = getToolByName(self.context, provider_id)
+                num_actions = len(provider.listActions())
+                if num_actions:
+                    provider.deleteActions(range(0,num_actions))
+
+            # BBB: for CMF 1.5 profiles
+            self._initOldstyleActions(child, mode)
+
+    def _initOldstyleActions(self, node, mode):
+        # BBB: for CMF 1.5 profiles
+        provider = getToolByName(self.context, node.getAttribute('id'))
+        for child in node.childNodes:
+            if child.nodeName != 'action':
+                continue
+
+            action_id = str(child.getAttribute('action_id'))
+            title = str(child.getAttribute('title'))
+            url_expr = str(child.getAttribute('url_expr'))
+            condition_expr = str(child.getAttribute('condition_expr'))
+            category = str(child.getAttribute('category'))
+            visible = str(child.getAttribute('visible'))
+            if visible.lower() == 'true':
+                visible = 1
+            else:
+                visible = 0
+
+            permission = ''
+            for permNode in child.childNodes:
+                if permNode.nodeName == 'permission':
+                    for textNode in permNode.childNodes:
+                        if textNode.nodeName != '#text' or \
+                               not textNode.nodeValue.strip():
+                            continue
+                        permission = str(textNode.nodeValue)
+                        break  # only one permission is allowed
+                    if permission:
+                        break
+
+            provider.addAction(action_id, title, url_expr,
+                               condition_expr, permission,
+                               category, visible)



More information about the CMF-checkins mailing list