[Erp5-report] r18361 - /erp5/trunk/products/ERP5/Tool/IdTool.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Mon Dec 17 16:10:46 CET 2007
Author: vincent
Date: Mon Dec 17 16:10:43 2007
New Revision: 18361
URL: http://svn.erp5.org?rev=18361&view=rev
Log:
Make it clear in function prototype that "store" is evaluated as a boolean.
Move all code relative to dict_length_ids in a code which access is controled by "store" value. This prevents portal_ids' persistent object modifications when "store" is false.
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=18361&r1=18360&r2=18361&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Tool/IdTool.py (original)
+++ erp5/trunk/products/ERP5/Tool/IdTool.py Mon Dec 17 16:10:43 2007
@@ -153,7 +153,7 @@
security.declareProtected(Permissions.AccessContentsInformation,
'generateNewLengthIdList')
def generateNewLengthIdList(self, id_group=None, id_count=1, default=None,
- store=1):
+ store=True):
"""
Generates a list of Ids.
The ids are generated using mysql and then stored in a Length object in a
@@ -167,11 +167,6 @@
store : if we want do store the new id into the zodb, we want it
by default
"""
- if getattr(self, 'dict_length_ids', None) is None:
- # Length objects are stored in a persistent mapping: there is one
- # Length object per id_group.
- self.dict_length_ids = PersistentMapping()
-
new_id = None
if id_group in (None, 'None'):
raise ValueError, '%s is not a valid group Id.' % (repr(id_group), )
@@ -194,9 +189,13 @@
finally:
commit()
new_id = result[0]['LAST_INSERT_ID()']
- if self.dict_length_ids.get(id_group) is None:
- self.dict_length_ids[id_group] = Length(new_id)
if store:
+ if getattr(self, 'dict_length_ids', None) is None:
+ # Length objects are stored in a persistent mapping: there is one
+ # Length object per id_group.
+ self.dict_length_ids = PersistentMapping()
+ if self.dict_length_ids.get(id_group) is None:
+ self.dict_length_ids[id_group] = Length(new_id)
self.dict_length_ids[id_group].set(new_id)
return range(new_id - id_count, new_id)
More information about the Erp5-report
mailing list