[Erp5-report] r8437 - /erp5/trunk/products/ERP5/Tool/IdTool.py

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Jul 14 15:19:04 CEST 2006


Author: seb
Date: Fri Jul 14 15:19:01 2006
New Revision: 8437

URL: http://svn.erp5.org?rev=8437&view=rev
Log:
do not call the method if wa take the default value

Modified:
    erp5/trunk/products/ERP5/Tool/IdTool.py

Modified: erp5/trunk/products/ERP5/Tool/IdTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Tool/IdTool.py?rev=8437&r1=8436&r2=8437&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Tool/IdTool.py (original)
+++ erp5/trunk/products/ERP5/Tool/IdTool.py Fri Jul 14 15:19:01 2006
@@ -85,13 +85,22 @@
       l = threading.Lock()
       l.acquire()
       try:
-        last_id = self.dict_ids.get(id_group, default or 0)
+        class Dummy:
+          pass
+        dummy = Dummy()
+        last_id = self.dict_ids.get(id_group, dummy)
+        if last_id is dummy:
+          if default is None:
+            new_id=0
+          else:
+            new_id=default
 
-        # Now generate a new id
-        if method is not None:
-          new_id = method(last_id)
         else:
-          new_id = last_id + 1
+          # Now generate a new id
+          if method is not None:
+            new_id = method(last_id)
+          else:
+            new_id = last_id + 1
  
         # Store the new value
         self.dict_ids[id_group] = new_id




More information about the Erp5-report mailing list