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

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Apr 24 15:57:02 CEST 2006


Author: vincent
Date: Mon Apr 24 15:56:59 2006
New Revision: 6900

URL: http://svn.erp5.org?rev=6900&view=rev
Log:
Remove outdated XXX.
Respect indentation width.


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=6900&r1=6899&r2=6900&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Tool/IdTool.py (original)
+++ erp5/trunk/products/ERP5/Tool/IdTool.py Mon Apr 24 15:56:59 2006
@@ -40,76 +40,63 @@
 from zLOG import LOG
 
 class IdTool(UniqueObject, Folder):
+  """
+    This tools handles the generation of IDs.
+  """
+  id = 'portal_ids'
+  meta_type = 'ERP5 Id Tool'
+  portal_type = 'Id Tool'
+  allowed_types = ( 'ERP5 Order Rule', 'ERP5 Transformation Rule',)
+
+  # Declarative Security
+  security = ClassSecurityInfo()
+
+  #
+  #   ZMI methods
+  #
+  manage_options = ( ( { 'label'      : 'Overview'
+                       , 'action'     : 'manage_overview'
+                       }
+                     ,
+                     )
+                   + Folder.manage_options
+                   )
+
+  security.declareProtected( Permissions.ManagePortal, 'manage_overview' )
+  manage_overview = DTMLFile( 'explainIdTool', _dtmldir )
+
+  # Filter content (ZMI))
+  def __init__(self):
+    return Folder.__init__(self, IdTool.id)
+        
+  # Filter content (ZMI))
+  def generateNewId(self, id_group=None, default=None, method=None):
     """
-    This tools allows to generate new ids
+      Generate a new Id
     """
-    id = 'portal_ids'
-    meta_type = 'ERP5 Id Tool'
-    portal_type = 'Id Tool'
-    allowed_types = ( 'ERP5 Order Rule', 'ERP5 Transformation Rule',)
+    if not hasattr(self,'dict_ids'):
+      self.dict_ids = PersistentMapping()
 
-    # Declarative Security
-    security = ClassSecurityInfo()
+    new_id = None
+    if id_group is not None and id_group!='None':
+      # Getting the last id
+      last_id = None
+      l = threading.Lock()
+      l.acquire()
+      try:
+        last_id = self.dict_ids.get(id_group, default or 0)
 
-    #
-    #   ZMI methods
-    #
-    manage_options = ( ( { 'label'      : 'Overview'
-                         , 'action'     : 'manage_overview'
-                         }
-                        ,
-                        )
-                     + Folder.manage_options
-                     )
+        # 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
+      finally:
+        l.release()
 
-    security.declareProtected( Permissions.ManagePortal, 'manage_overview' )
-    manage_overview = DTMLFile( 'explainIdTool', _dtmldir )
-
-    # Filter content (ZMI))
-    def __init__(self):
-      return Folder.__init__(self, IdTool.id)
-        
-
-    # Filter content (ZMI))
-    def generateNewId(self, id_group=None, default=None, method=None):
-      """
-      Generate a new Id
-
-      XXX We should in the future use class instead of method to generate
-      new ids. It would be nice to have a management page giving the list
-      of id_group with each time the last_id and the class generator
-      """
-      if not hasattr(self,'dict_ids'):
-        self.dict_ids = PersistentMapping()
-
-      new_id = None
-      if id_group is not None and id_group!='None':
-        # Getting the last id
-        last_id = None
-        l = threading.Lock()
-        l.acquire()
-        try:
-          if self.dict_ids.has_key(id_group):
-            last_id = self.dict_ids[id_group]
-          elif default is not None:
-            last_id = default
-          else:
-            last_id = 0
-
-          # 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
-        finally:
-          l.release()
-
-      return new_id
-
-
-
+    return new_id
 
 InitializeClass(IdTool)




More information about the Erp5-report mailing list