[Checkins] SVN: Products.GenericSetup/branches/1.4/Products/GenericSetup/ Avoid even an explicit purge of the rolemap if no XML file is present
Tres Seaver
tseaver at palladion.com
Mon Oct 6 21:34:33 EDT 2008
Log message for revision 91824:
Avoid even an explicit purge of the rolemap if no XML file is present
- See https://bugs.launchpad.net/zope-cmf/+bug/279294
Changed:
U Products.GenericSetup/branches/1.4/Products/GenericSetup/CHANGES.txt
U Products.GenericSetup/branches/1.4/Products/GenericSetup/rolemap.py
U Products.GenericSetup/branches/1.4/Products/GenericSetup/tests/test_rolemap.py
-=-
Modified: Products.GenericSetup/branches/1.4/Products/GenericSetup/CHANGES.txt
===================================================================
--- Products.GenericSetup/branches/1.4/Products/GenericSetup/CHANGES.txt 2008-10-07 01:34:04 UTC (rev 91823)
+++ Products.GenericSetup/branches/1.4/Products/GenericSetup/CHANGES.txt 2008-10-07 01:34:32 UTC (rev 91824)
@@ -1,6 +1,12 @@
GenericSetup Product Changelog
==============================
+GenericSetup 1.4.3 (unreleased)
+-------------------------------
+
+- Avoid even an explicit purge of the rolemap if no XML file is present
+ in a given context. (https://bugs.launchpad.net/zope-cmf/+bug/279294)
+
GenericSetup 1.4.2.2 (2008-09-22)
---------------------------------
Modified: Products.GenericSetup/branches/1.4/Products/GenericSetup/rolemap.py
===================================================================
--- Products.GenericSetup/branches/1.4/Products/GenericSetup/rolemap.py 2008-10-07 01:34:04 UTC (rev 91823)
+++ Products.GenericSetup/branches/1.4/Products/GenericSetup/rolemap.py 2008-10-07 01:34:32 UTC (rev 91824)
@@ -63,21 +63,21 @@
encoding = context.getEncoding()
logger = context.getLogger('rolemap')
- if context.shouldPurge():
+ text = context.readDataFile( _FILENAME )
- items = site.__dict__.items()
+ if text is not None:
- for k, v in items: # XXX: WAAA
+ if context.shouldPurge():
- if k == '__ac_roles__':
- delattr( site, k )
+ items = site.__dict__.items()
- if k.startswith( '_' ) and k.endswith( '_Permission' ):
- delattr( site, k )
+ for k, v in items: # XXX: WAAA
- text = context.readDataFile( _FILENAME )
+ if k == '__ac_roles__':
+ delattr( site, k )
- if text is not None:
+ if k.startswith( '_' ) and k.endswith( '_Permission' ):
+ delattr( site, k )
rc = RolemapImportConfigurator(site, encoding)
rolemap_info = rc.parseXML( text )
Modified: Products.GenericSetup/branches/1.4/Products/GenericSetup/tests/test_rolemap.py
===================================================================
--- Products.GenericSetup/branches/1.4/Products/GenericSetup/tests/test_rolemap.py 2008-10-07 01:34:04 UTC (rev 91823)
+++ Products.GenericSetup/branches/1.4/Products/GenericSetup/tests/test_rolemap.py 2008-10-07 01:34:32 UTC (rev 91824)
@@ -469,6 +469,44 @@
layer = ExportImportZCMLLayer
+ def test_existing_roles_missing_xml_doesnt_purge(self):
+ # LP # 279294
+ ACI = 'Access contents information'
+ VIEW = 'View'
+
+ self.app.site = Folder(id='site')
+ site = self.app.site # wrap
+ original_roles = list(getattr(site, '__ac_roles__', []))[:]
+ modified_roles = original_roles[:]
+ modified_roles.append('ZZZ')
+
+ site.__ac_roles__ = modified_roles
+ site.manage_permission(VIEW, ())
+ site.manage_permission(ACI, ('Manager', 'ZZZ'))
+
+ existing_allowed = [x['name'] for x in site.rolesOfPermission(ACI)
+ if x['selected']]
+
+ self.assertEqual(existing_allowed, ['Manager', 'ZZZ'])
+
+ context = DummyImportContext(site, True)
+ #context._files[ 'rolemap.xml' ] = _EMPTY_EXPORT # no file!
+
+ from Products.GenericSetup.rolemap import importRolemap
+ importRolemap(context)
+
+ new_roles = list(getattr(site, '__ac_roles__', []))[:]
+
+ modified_roles.sort()
+ new_roles.sort()
+
+ self.assertEqual(modified_roles, new_roles)
+
+ new_allowed = [x['name'] for x in site.rolesOfPermission(ACI)
+ if x['selected']]
+
+ self.assertEqual(new_allowed, existing_allowed)
+
def test_empty_default_purge( self ):
self.app.site = Folder(id='site')
More information about the Checkins
mailing list