[CMF-checkins] CVS: CMF/CMFSetup - actions.py:1.14 permissions.py:1.4 typeinfo.py:1.14 workflow.py:1.29

Martijn Pieters mj at zopatista.com
Wed Nov 10 08:06:18 EST 2004


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

Modified Files:
	actions.py permissions.py typeinfo.py workflow.py 
Log Message:
CMF-1.4 compatible version of CMFSetup.


=== CMF/CMFSetup/actions.py 1.13 => 1.14 ===
--- CMF/CMFSetup/actions.py:1.13	Thu Aug 12 11:07:41 2004
+++ CMF/CMFSetup/actions.py	Wed Nov 10 08:05:47 2004
@@ -168,7 +168,8 @@
             if actions and isinstance(actions[0], dict):
                 continue
 
-            provider_info['actions'] = [ ai.getMapping() for ai in actions ]
+            provider_info['actions'] = [ self._makeActionMapping(ai) 
+                                         for ai in actions ]
 
         return result
 
@@ -193,6 +194,22 @@
 
         root = dom.getElementsByTagName('actions-tool')[0]
         return _extractActionProviderNodes(root, encoding)
+
+    security.declarePrivate( '_makeActionMapping' )
+    def _makeActionMapping( self, ai ):
+        
+        """ Convert a ActionInformation object into the appropriate mapping.
+        """
+        return  { 'id'         : ai.id
+                , 'title'      : ai.title or ai.id
+                , 'description': ai.description
+                , 'category'   : ai.category or 'object'
+                , 'condition'  : getattr(ai, 'condition', None) 
+                                     and ai.condition.text or ''
+                , 'permissions': ai.permissions
+                , 'visible'    : bool(ai.visible)
+                , 'action'     : ai.getActionExpression()
+                }
 
 InitializeClass( ActionProvidersConfigurator )
 


=== CMF/CMFSetup/permissions.py 1.3 => 1.4 ===
--- CMF/CMFSetup/permissions.py:1.3	Thu Aug 12 11:07:41 2004
+++ CMF/CMFSetup/permissions.py	Wed Nov 10 08:05:47 2004
@@ -15,4 +15,4 @@
 $Id$
 """
 
-from Products.CMFCore.permissions import ManagePortal
+from Products.CMFCore.CMFCorePermissions import ManagePortal


=== CMF/CMFSetup/typeinfo.py 1.13 => 1.14 ===
--- CMF/CMFSetup/typeinfo.py:1.13	Wed Oct  6 06:02:30 2004
+++ CMF/CMFSetup/typeinfo.py	Wed Nov 10 08:05:47 2004
@@ -217,7 +217,6 @@
                  , 'filter_content_types'   : bool(ti.filter_content_types)
                  , 'allowed_content_types'  : ti.allowed_content_types
                  , 'allow_discussion'       : bool(ti.allow_discussion)
-                 , 'aliases'                : ti.getMethodAliases()
                  }
 
         if ' ' in ti.getId():
@@ -237,10 +236,25 @@
             result[ 'constructor_path' ] = ti.constructor_path
 
         actions = ti.listActions()
-        result['actions'] = [ ai.getMapping() for ai in actions ]
+        result['actions'] = [ self._makeActionMapping(ai) for ai in actions ]
 
         return result
 
+    security.declarePrivate( '_makeActionMapping' )
+    def _makeActionMapping( self, ai ):
+        
+        """ Convert a ActionInformation object into the appropriate mapping.
+        """
+        return  { 'id'         : ai.id
+                , 'title'      : ai.title or ai.id
+                , 'description': ai.description
+                , 'category'   : ai.category or 'object'
+                , 'condition'  : getattr(ai, 'condition', None) 
+                                     and ai.condition.text or ''
+                , 'permissions': ai.permissions
+                , 'visible'    : bool(ai.visible)
+                , 'action'     : ai.getActionExpression()
+                }
 
 InitializeClass( TypeInfoConfigurator )
 
@@ -298,7 +312,6 @@
     filter_content_types  = _qb('filter_content_types', False)
     allowed_content_types = _extractAllowedContentTypeNodes(ti_node, encoding)
     allow_discussion      = _qb('allow_discussion', False)
-    aliases               = _extractAliasesNode(ti_node, encoding)
     actions               = _extractActionNodes(ti_node, encoding)
 
     info = { 'id': type_id,
@@ -312,7 +325,6 @@
              'filter_content_types': filter_content_types,
              'allowed_content_types': allowed_content_types,
              'allow_discussion': allow_discussion,
-             'aliases': aliases,
              'actions': actions }
 
     if kind == FactoryTypeInformation.meta_type:
@@ -335,20 +347,6 @@
         result.append(value)
 
     return tuple(result)
-
-def _extractAliasesNode(parent, encoding=None):
-
-    result = {}
-
-    aliases = parent.getElementsByTagName('aliases')[0]
-    for alias in aliases.getElementsByTagName('alias'):
-
-        alias_from = _getNodeAttribute(alias, 'from', encoding)
-        alias_to = _getNodeAttribute(alias, 'to', encoding)
-
-        result[alias_from] = alias_to
-
-    return result
 
 def _getTypeFilename( type_id ):
 


=== CMF/CMFSetup/workflow.py 1.28 => 1.29 ===
--- CMF/CMFSetup/workflow.py:1.28	Wed Oct  6 06:02:30 2004
+++ CMF/CMFSetup/workflow.py	Wed Nov 10 08:05:47 2004
@@ -421,8 +421,6 @@
           'guard_roles' -- a list of roles guarding access
             to the variable
 
-          'guard_groups' -- a list of groups guarding the transition
-
           'guard_expr' -- an expression guarding access to the variable
         """
         result = []
@@ -446,7 +444,6 @@
                    , 'default_expr'         : v.getDefaultExprText()
                    , 'guard_permissions'    : guard.permissions
                    , 'guard_roles'          : guard.roles
-                   , 'guard_groups'         : guard.groups
                    , 'guard_expr'           : guard.getExprText()
                    }
 
@@ -472,9 +469,6 @@
           'permissions' -- a list of mappings describing the permission
             map for the state
 
-          'groups' -- a list of ( group_id, (roles,) ) tuples describing the
-            group-role assignments for the state
-
           'variables' -- a list of mapping for the variables
             to be set when entering the state.
 
@@ -504,10 +498,6 @@
 
         for k, v in items:
 
-            groups = v.group_roles and list( v.group_roles.items() ) or []
-            groups = [ x for x in groups if x[1] ]
-            groups.sort()
-
             variables = list( v.getVariableValues() )
             variables.sort()
 
@@ -524,7 +514,6 @@
                    , 'description'  : v.description
                    , 'transitions'  : v.transitions
                    , 'permissions'  : self._extractStatePermissions( v )
-                   , 'groups'       : groups
                    , 'variables'    : v_info
                    }
 
@@ -606,8 +595,6 @@
 
           'guard_roles' -- a list of roles guarding the transition
 
-          'guard_groups' -- a list of groups guarding the transition
-
           'guard_expr' -- an expression guarding the transition
 
         """
@@ -638,7 +625,6 @@
                    , 'variables'            : v_info
                    , 'guard_permissions'    : guard.permissions
                    , 'guard_roles'          : guard.roles
-                   , 'guard_groups'         : guard.groups
                    , 'guard_expr'           : guard.getExprText()
                    }
 
@@ -701,7 +687,6 @@
                    , 'actbox_category'      : v.actbox_category
                    , 'guard_permissions'    : guard.permissions
                    , 'guard_roles'          : guard.roles
-                   , 'guard_groups'         : guard.groups
                    , 'guard_expr'           : guard.getExprText()
                    }
 
@@ -848,18 +833,6 @@
 
             permission_map[ name ] = roles
 
-        info[ 'groups' ] = group_map = []
-
-        for g_map in s_node.getElementsByTagName( 'group-map' ):
-
-            name = _getNodeAttribute( g_map, 'name', encoding )
-
-            roles = [ _coalesceTextNodeChildren( x, encoding )
-                        for x in g_map.getElementsByTagName(
-                                            'group-role' ) ]
-
-            group_map.append( ( name, tuple( roles ) ) )
-
         info[ 'variables' ] = var_map = {}
 
         for assignment in s_node.getElementsByTagName( 'assignment' ):
@@ -1006,7 +979,7 @@
     assert len( nodes ) <= 1, nodes
 
     if len( nodes ) < 1:
-        return { 'permissions' : (), 'roles' : (), 'groups' : (), 'expr' : '' }
+        return { 'permissions' : (), 'roles' : (), 'expr' : '' }
 
     node = nodes[ 0 ]
 
@@ -1022,8 +995,6 @@
                                                     'guard-permission' ) ]
            , 'roles' : [ _coalesceTextNodeChildren( x, encoding )
                           for x in node.getElementsByTagName( 'guard-role' ) ]
-           , 'groups' : [ _coalesceTextNodeChildren( x, encoding )
-                          for x in node.getElementsByTagName( 'guard-group' ) ]
            , 'expression' : expr_text
            }
 
@@ -1192,7 +1163,6 @@
         guard = v_info[ 'guard' ]
         props = { 'guard_roles' : ';'.join( guard[ 'roles' ] )
                 , 'guard_permissions' : ';'.join( guard[ 'permissions' ] )
-                , 'guard_groups' : ';'.join( guard[ 'groups' ] )
                 , 'guard_expr' : guard[ 'expression' ]
                 }
 
@@ -1232,11 +1202,6 @@
         for k, v in s_info[ 'permissions' ].items():
             s.setPermission( k, type( v ) is type( [] ), v )
 
-        gmap = s.group_roles = PersistentMapping()
-
-        for group_id, roles in s_info[ 'groups' ]:
-            gmap[ group_id ] = roles
-
         vmap = s.var_values = PersistentMapping()
 
         for name, v_info in s_info[ 'variables' ].items():
@@ -1268,7 +1233,6 @@
         guard = t_info[ 'guard' ]
         props = { 'guard_roles' : ';'.join( guard[ 'roles' ] )
                 , 'guard_permissions' : ';'.join( guard[ 'permissions' ] )
-                , 'guard_groups' : ';'.join( guard[ 'groups' ] )
                 , 'guard_expr' : guard[ 'expression' ]
                 }
 
@@ -1306,7 +1270,6 @@
         guard = w_info[ 'guard' ]
         props = { 'guard_roles' : ';'.join( guard[ 'roles' ] )
                 , 'guard_permissions' : ';'.join( guard[ 'permissions' ] )
-                , 'guard_groups' : ';'.join( guard[ 'groups' ] )
                 , 'guard_expr' : guard[ 'expression' ]
                 }
 



More information about the CMF-checkins mailing list