[Erp5-report] r36288 jm - /erp5/trunk/products/ERP5/Document/

nobody at svn.erp5.org nobody at svn.erp5.org
Sat Jun 12 18:49:06 CEST 2010


Author: jm
Date: Sat Jun 12 18:49:06 2010
New Revision: 36288

URL: http://svn.erp5.org?rev=36288&view=rev
Log:
Do not modify ZODB Id Generator whenever a id is generated

Also simplify code to handle default value.

Modified:
    erp5/trunk/products/ERP5/Document/ZODBContinuousIncreasingIdGenerator.py

Modified: erp5/trunk/products/ERP5/Document/ZODBContinuousIncreasingIdGenerator.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/ZODBContinuousIncreasingIdGenerator.py?rev=36288&r1=36287&r2=36288&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/ZODBContinuousIncreasingIdGenerator.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/ZODBContinuousIncreasingIdGenerator.py [utf8] Sat Jun 12 18:49:06 2010
@@ -58,23 +58,15 @@ class ZODBContinuousIncreasingIdGenerato
       raise ValueError, '%s is not a valid group Id.' % (repr(id_group), )
     if default is None:
       default = 0
-    self.last_id_dict = getattr(self, 'last_id_dict', None)
-    if self.last_id_dict is None:
+    last_id_dict = getattr(self, 'last_id_dict', None)
+    if last_id_dict is None:
       # If the dictionary not exist initialize generator
       self.initializeGenerator()
-    marker = []
-    # Retrieve the last id
-    last_id = self.last_id_dict.get(id_group, marker)
-    if last_id is marker:
-      new_id = default
-      if id_count > 1:
-        # If create a list use the default and increment
-        new_id = new_id + id_count - 1
-    else:
-      # Increment the last_id
-      new_id = last_id + id_count
+      last_id_dict = self.last_id_dict
+    # Retrieve the last id and increment
+    new_id = last_id_dict.get(id_group, default - 1) + id_count
     # Store the new_id in the dictionary
-    self.last_id_dict[id_group] = new_id
+    last_id_dict[id_group] = new_id
     return new_id
 
   security.declareProtected(Permissions.AccessContentsInformation,




More information about the Erp5-report mailing list