[CMF-checkins] CVS: CMF/CMFSetup - rolemap.py:1.9
Tres Seaver
tseaver at zope.com
Tue Jun 8 16:01:28 EDT 2004
Update of /cvs-repository/CMF/CMFSetup
In directory cvs.zope.org:/tmp/cvs-serv3724
Modified Files:
rolemap.py
Log Message:
- Ensure that 'parse*XML' steps return data structures, rather than side effects.
=== CMF/CMFSetup/rolemap.py 1.8 => 1.9 ===
--- CMF/CMFSetup/rolemap.py:1.8 Sat May 29 21:52:30 2004
+++ CMF/CMFSetup/rolemap.py Tue Jun 8 16:01:26 2004
@@ -65,7 +65,29 @@
if text is not None:
rc = RolemapConfigurator( site ).__of__( site )
- rc.parseXML( text )
+ roles, permissions = rc.parseXML( text )
+
+ immediate_roles = list( getattr( site, '__ac_roles__', [] ) )[:]
+ already = {}
+
+ for role in site.valid_roles():
+ already[ role ] = 1
+
+ for role in roles:
+
+ if already.get( role ) is None:
+ immediate_roles.append( role )
+ already[ role ] = 1
+
+ immediate_roles.sort()
+ site.__ac_roles__ = tuple( immediate_roles )
+
+ for permission in permissions:
+
+ site.manage_permission( permission[ 'name' ]
+ , permission[ 'roles' ]
+ , permission[ 'acquire' ]
+ )
return 'Role / permission map imported.'
@@ -183,26 +205,7 @@
parser = _RolemapParser()
parseString( text, parser )
- immediate_roles = list( getattr( self._site, '__ac_roles__', [] ) )[:]
- already = {}
- for role in self._site.valid_roles():
- already[ role ] = 1
-
- for role in parser._roles:
-
- if already.get( role ) is None:
- immediate_roles.append( role )
- already[ role ] = 1
-
- immediate_roles.sort()
- self._site.__ac_roles__ = tuple( immediate_roles )
-
- for permission in parser._permissions:
-
- self._site.manage_permission( permission[ 'name' ]
- , permission[ 'roles' ]
- , permission[ 'acquire' ]
- )
+ return parser._roles, parser._permissions
InitializeClass( RolemapConfigurator )
More information about the CMF-checkins
mailing list