[Erp5-report] r16299 - /erp5/trunk/products/ZSQLCatalog/SQLCatalog.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed Sep 12 15:57:56 CEST 2007
Author: seb
Date: Wed Sep 12 15:57:55 2007
New Revision: 16299
URL: http://svn.erp5.org?rev=16299&view=rev
Log:
make the security uid generation working with many nodes, use the id_tool in order to generate new ids, so it is possible to have multiple nodes generating new security uids by the same time without errors
Modified:
erp5/trunk/products/ZSQLCatalog/SQLCatalog.py
Modified: erp5/trunk/products/ZSQLCatalog/SQLCatalog.py
URL: http://svn.erp5.org/erp5/trunk/products/ZSQLCatalog/SQLCatalog.py?rev=16299&r1=16298&r2=16299&view=diff
==============================================================================
--- erp5/trunk/products/ZSQLCatalog/SQLCatalog.py (original)
+++ erp5/trunk/products/ZSQLCatalog/SQLCatalog.py Wed Sep 12 15:57:55 2007
@@ -960,7 +960,7 @@
def _clearSecurityCache(self):
self.security_uid_dict = OIBTree()
- self.security_uid_index = Length()
+ self.security_uid_index = None
security.declarePrivate('getSecurityUid')
def getSecurityUid(self, wrapped_object):
@@ -981,8 +981,31 @@
self._clearSecurityCache()
if self.security_uid_dict.has_key(allowed_roles_and_users):
return (self.security_uid_dict[allowed_roles_and_users], None)
- self.security_uid_index.change(1)
- security_uid = self.security_uid_index()
+ # If the id_tool is there, it is better to use it, it allows
+ # to create many new security uids by the same time
+ # because with this tool we are sure that we will have 2 different
+ # uids if two instances are doing this code in the same time
+ id_tool = getattr(self.getPortalObject(), 'portal_ids', None)
+ if id_tool is not None:
+ default = 1
+ # We must keep compatibility with existing sites
+ if getattr(self, 'security_uid_index', None) is not None:
+ # At some point, it was a Length
+ if isinstance(previous_security_uid, Length):
+ default = previous_security_uid() + 1
+ else:
+ default = self.security_uid_index
+ security_uid = id_tool.generateNewLengthId(id_group='security_uid_index',
+ default=default)
+ else:
+ previous_security_uid = getattr(self, 'security_uid_index', None)
+ if previous_security_uid is None:
+ previous_security_uid = 0
+ # At some point, it was a Length
+ if isinstance(previous_security_uid, Length):
+ previous_security_uid = previous_security_uid()
+ security_uid = previous_security_uid + 1
+ self.security_uid_index = security_uid
self.security_uid_dict[allowed_roles_and_users] = security_uid
return (security_uid, allowed_roles_and_users)
More information about the Erp5-report
mailing list