From afb802af203e79c947be75797eb0d1e7dba3ecb3 Mon Sep 17 00:00:00 2001 From: Vincent Pelletier <vincent@nexedi.com> Date: Mon, 24 Apr 2006 13:56:59 +0000 Subject: [PATCH] Remove outdated XXX. Respect indentation width. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@6900 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5/Tool/IdTool.py | 119 ++++++++++++++++-------------------- 1 file changed, 53 insertions(+), 66 deletions(-) diff --git a/product/ERP5/Tool/IdTool.py b/product/ERP5/Tool/IdTool.py index e0941986b7..9a730406a0 100644 --- a/product/ERP5/Tool/IdTool.py +++ b/product/ERP5/Tool/IdTool.py @@ -40,76 +40,63 @@ import threading from zLOG import LOG class IdTool(UniqueObject, Folder): - """ - This tools allows to generate new 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 + """ + 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 ) + 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 __init__(self): + return Folder.__init__(self, IdTool.id) - - # Filter content (ZMI)) - def generateNewId(self, id_group=None, default=None, method=None): - """ + # 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 - - - + """ + 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: + last_id = self.dict_ids.get(id_group, default or 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 InitializeClass(IdTool) -- 2.30.9