[Checkins] SVN: Products.PluggableAuthService/branches/1.5/Products/PluggableAuthService/ ensure ZODBRoleManagerExportImport doesn't fail if it tries to register a role

Rob Miller ra at burningman.com
Tue Jun 10 22:01:50 EDT 2008


Log message for revision 87307:
  ensure ZODBRoleManagerExportImport doesn't fail if it tries to register a role
  that already exists
  

Changed:
  U   Products.PluggableAuthService/branches/1.5/Products/PluggableAuthService/doc/CHANGES.txt
  U   Products.PluggableAuthService/branches/1.5/Products/PluggableAuthService/plugins/exportimport.py

-=-
Modified: Products.PluggableAuthService/branches/1.5/Products/PluggableAuthService/doc/CHANGES.txt
===================================================================
--- Products.PluggableAuthService/branches/1.5/Products/PluggableAuthService/doc/CHANGES.txt	2008-06-11 02:00:16 UTC (rev 87306)
+++ Products.PluggableAuthService/branches/1.5/Products/PluggableAuthService/doc/CHANGES.txt	2008-06-11 02:01:50 UTC (rev 87307)
@@ -1,5 +1,13 @@
 PluggableAuthService changelog
 
+  PluggableAuthService 1.5.4 (Unreleased)
+
+    Bugs Fixed
+
+      - Ensure ZODBRoleManagerExportImport doesn't fail if it tries to add a
+        role that already exists (idempotence is desirable in GS importers)
+
+
   PluggableAuthService 1.5.3 (2008/02/06)
 
     Bugs Fixed

Modified: Products.PluggableAuthService/branches/1.5/Products/PluggableAuthService/plugins/exportimport.py
===================================================================
--- Products.PluggableAuthService/branches/1.5/Products/PluggableAuthService/plugins/exportimport.py	2008-06-11 02:00:16 UTC (rev 87306)
+++ Products.PluggableAuthService/branches/1.5/Products/PluggableAuthService/plugins/exportimport.py	2008-06-11 02:01:50 UTC (rev 87307)
@@ -241,7 +241,11 @@
             title = self._getNodeAttr(role, 'title', None)
             description = self._getNodeAttr(role, 'description', None)
 
-            self.context.addRole(role_id, title, description)
+            try:
+                self.context.addRole(role_id, title, description)
+            except KeyError:
+                # it's fine if the role already exists
+                pass
 
             for principal in role.getElementsByTagName('principal'):
                 principal_id = self._getNodeAttr(principal, 'principal_id', None)



More information about the Checkins mailing list