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
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)
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