Commit afb802af authored by Vincent Pelletier's avatar Vincent Pelletier

Remove outdated XXX.

Respect indentation width.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@6900 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 36ec65be
...@@ -40,76 +40,63 @@ import threading ...@@ -40,76 +40,63 @@ import threading
from zLOG import LOG from zLOG import LOG
class IdTool(UniqueObject, Folder): class IdTool(UniqueObject, Folder):
""" """
This tools allows to generate new ids This tools handles the generation of IDs.
""" """
id = 'portal_ids' id = 'portal_ids'
meta_type = 'ERP5 Id Tool' meta_type = 'ERP5 Id Tool'
portal_type = 'Id Tool' portal_type = 'Id Tool'
allowed_types = ( 'ERP5 Order Rule', 'ERP5 Transformation Rule',) allowed_types = ( 'ERP5 Order Rule', 'ERP5 Transformation Rule',)
# Declarative Security # Declarative Security
security = ClassSecurityInfo() security = ClassSecurityInfo()
# #
# ZMI methods # ZMI methods
# #
manage_options = ( ( { 'label' : 'Overview' manage_options = ( ( { 'label' : 'Overview'
, 'action' : 'manage_overview' , 'action' : 'manage_overview'
} }
, ,
)
+ Folder.manage_options
) )
+ Folder.manage_options
)
security.declareProtected( Permissions.ManagePortal, 'manage_overview' ) security.declareProtected( Permissions.ManagePortal, 'manage_overview' )
manage_overview = DTMLFile( 'explainIdTool', _dtmldir ) manage_overview = DTMLFile( 'explainIdTool', _dtmldir )
# Filter content (ZMI)) # Filter content (ZMI))
def __init__(self): def __init__(self):
return Folder.__init__(self, IdTool.id) return Folder.__init__(self, IdTool.id)
# Filter content (ZMI))
# Filter content (ZMI)) def generateNewId(self, id_group=None, default=None, method=None):
def generateNewId(self, id_group=None, default=None, method=None): """
"""
Generate a new Id Generate a new Id
"""
XXX We should in the future use class instead of method to generate if not hasattr(self,'dict_ids'):
new ids. It would be nice to have a management page giving the list self.dict_ids = PersistentMapping()
of id_group with each time the last_id and the class generator
""" new_id = None
if not hasattr(self,'dict_ids'): if id_group is not None and id_group!='None':
self.dict_ids = PersistentMapping() # Getting the last id
last_id = None
new_id = None l = threading.Lock()
if id_group is not None and id_group!='None': l.acquire()
# Getting the last id try:
last_id = None last_id = self.dict_ids.get(id_group, default or 0)
l = threading.Lock()
l.acquire() # Now generate a new id
try: if method is not None:
if self.dict_ids.has_key(id_group): new_id = method(last_id)
last_id = self.dict_ids[id_group] else:
elif default is not None: new_id = last_id + 1
last_id = default
else: # Store the new value
last_id = 0 self.dict_ids[id_group] = new_id
finally:
# Now generate a new id l.release()
if method is not None:
new_id = method(last_id) return new_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) InitializeClass(IdTool)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment