[CMF-checkins] CVS: CMF/CMFSetup - actions.py:1.15
permissions.py:1.5 typeinfo.py:1.15 workflow.py:1.30
Martijn Pieters
mj at zopatista.com
Wed Nov 10 08:12:50 EST 2004
Update of /cvs-repository/CMF/CMFSetup
In directory cvs.zope.org:/tmp/cvs-serv11006
Modified Files:
actions.py permissions.py typeinfo.py workflow.py
Log Message:
Oops, checked into the HEAD instead of into the branch. Mea Culpa.
=== CMF/CMFSetup/actions.py 1.14 => 1.15 ===
--- CMF/CMFSetup/actions.py:1.14 Wed Nov 10 08:05:47 2004
+++ CMF/CMFSetup/actions.py Wed Nov 10 08:12:20 2004
@@ -168,8 +168,7 @@
if actions and isinstance(actions[0], dict):
continue
- provider_info['actions'] = [ self._makeActionMapping(ai)
- for ai in actions ]
+ provider_info['actions'] = [ ai.getMapping() for ai in actions ]
return result
@@ -194,22 +193,6 @@
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.4 => 1.5 ===
--- CMF/CMFSetup/permissions.py:1.4 Wed Nov 10 08:05:47 2004
+++ CMF/CMFSetup/permissions.py Wed Nov 10 08:12:20 2004
@@ -15,4 +15,4 @@
$Id$
"""
-from Products.CMFCore.CMFCorePermissions import ManagePortal
+from Products.CMFCore.permissions import ManagePortal
=== CMF/CMFSetup/typeinfo.py 1.14 => 1.15 ===
--- CMF/CMFSetup/typeinfo.py:1.14 Wed Nov 10 08:05:47 2004
+++ CMF/CMFSetup/typeinfo.py Wed Nov 10 08:12:20 2004
@@ -217,6 +217,7 @@
, '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():
@@ -236,25 +237,10 @@
result[ 'constructor_path' ] = ti.constructor_path
actions = ti.listActions()
- result['actions'] = [ self._makeActionMapping(ai) for ai in actions ]
+ result['actions'] = [ ai.getMapping() 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 )
@@ -312,6 +298,7 @@
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,
@@ -325,6 +312,7 @@
'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:
@@ -347,6 +335,20 @@
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.29 => 1.30 ===
--- CMF/CMFSetup/workflow.py:1.29 Wed Nov 10 08:05:47 2004
+++ CMF/CMFSetup/workflow.py Wed Nov 10 08:12:20 2004
@@ -421,6 +421,8 @@
'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 = []
@@ -444,6 +446,7 @@
, 'default_expr' : v.getDefaultExprText()
, 'guard_permissions' : guard.permissions
, 'guard_roles' : guard.roles
+ , 'guard_groups' : guard.groups
, 'guard_expr' : guard.getExprText()
}
@@ -469,6 +472,9 @@
'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.
@@ -498,6 +504,10 @@
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()
@@ -514,6 +524,7 @@
, 'description' : v.description
, 'transitions' : v.transitions
, 'permissions' : self._extractStatePermissions( v )
+ , 'groups' : groups
, 'variables' : v_info
}
@@ -595,6 +606,8 @@
'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
"""
@@ -625,6 +638,7 @@
, 'variables' : v_info
, 'guard_permissions' : guard.permissions
, 'guard_roles' : guard.roles
+ , 'guard_groups' : guard.groups
, 'guard_expr' : guard.getExprText()
}
@@ -687,6 +701,7 @@
, 'actbox_category' : v.actbox_category
, 'guard_permissions' : guard.permissions
, 'guard_roles' : guard.roles
+ , 'guard_groups' : guard.groups
, 'guard_expr' : guard.getExprText()
}
@@ -833,6 +848,18 @@
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' ):
@@ -979,7 +1006,7 @@
assert len( nodes ) <= 1, nodes
if len( nodes ) < 1:
- return { 'permissions' : (), 'roles' : (), 'expr' : '' }
+ return { 'permissions' : (), 'roles' : (), 'groups' : (), 'expr' : '' }
node = nodes[ 0 ]
@@ -995,6 +1022,8 @@
'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
}
@@ -1163,6 +1192,7 @@
guard = v_info[ 'guard' ]
props = { 'guard_roles' : ';'.join( guard[ 'roles' ] )
, 'guard_permissions' : ';'.join( guard[ 'permissions' ] )
+ , 'guard_groups' : ';'.join( guard[ 'groups' ] )
, 'guard_expr' : guard[ 'expression' ]
}
@@ -1202,6 +1232,11 @@
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():
@@ -1233,6 +1268,7 @@
guard = t_info[ 'guard' ]
props = { 'guard_roles' : ';'.join( guard[ 'roles' ] )
, 'guard_permissions' : ';'.join( guard[ 'permissions' ] )
+ , 'guard_groups' : ';'.join( guard[ 'groups' ] )
, 'guard_expr' : guard[ 'expression' ]
}
@@ -1270,6 +1306,7 @@
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