[Erp5-report] r43794 jerome - /erp5/trunk/products/ERP5/Tool/IdTool.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Mon Feb 28 10:59:04 CET 2011
Author: jerome
Date: Mon Feb 28 10:59:04 2011
New Revision: 43794
URL: http://svn.erp5.org?rev=43794&view=rev
Log:
fix a few typos and try to make warning messages more informative.
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=43794&r1=43793&r2=43794&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Tool/IdTool.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Tool/IdTool.py [utf8] Mon Feb 28 10:59:04 2011
@@ -117,18 +117,16 @@ class IdTool(BaseTool):
Generate the next id in the sequence of ids of a particular group
"""
if id_group in (None, 'None'):
- raise ValueError, '%s is not a valid group Id.' % (repr(id_group), )
+ raise ValueError, '%s is not a valid id_group' % (repr(id_group), )
# for compatibilty with sql data, must not use id_group as a list
if not isinstance(id_group, str):
id_group = repr(id_group)
- warnings.warn('The id_group must be a string the other types '
- 'is deprecated.', DeprecationWarning)
+ warnings.warn('id_group must be a string, other types '
+ 'are deprecated.', DeprecationWarning)
if id_generator is None:
id_generator = 'document'
if method is not _marker:
- warnings.warn("The usage of 'method' argument is deprecated.\n"
- "use this method with a id generator without this"
- "argument", DeprecationWarning)
+ warnings.warn("Use of 'method' argument is deprecated", DeprecationWarning)
try:
#use _getLatestGeneratorValue here for that the technical level
#must not call the method
@@ -145,9 +143,9 @@ class IdTool(BaseTool):
else:
# Compatibility code below, in case the last version of erp5_core
# is not installed yet
- warnings.warn("You use the old version of API which is deprecated.\n"
- "please, update the business template erp5_core "
- "to use the new API", DeprecationWarning)
+ warnings.warn("You are using an old version of erp5_core to generate"
+ "ids.\nPlease update erp5_core business template to "
+ "use new id generators", DeprecationWarning)
dict_ids = getattr(aq_base(self), 'dict_ids', None)
if dict_ids is None:
dict_ids = self.dict_ids = PersistentMapping()
@@ -178,18 +176,17 @@ class IdTool(BaseTool):
Generate a list of next ids in the sequence of ids of a particular group
"""
if id_group in (None, 'None'):
- raise ValueError, '%s is not a valid group Id.' % (repr(id_group), )
+ raise ValueError, '%s is not a valid id_group' % (repr(id_group), )
# for compatibilty with sql data, must not use id_group as a list
if not isinstance(id_group, str):
id_group = repr(id_group)
- warnings.warn('The id_group must be a string the other types '
- 'is deprecated.', DeprecationWarning)
+ warnings.warn('id_group must be a string, other types '
+ 'are deprecated.', DeprecationWarning)
if id_generator is None:
id_generator = 'uid'
if store is not _marker:
- warnings.warn("The usage of 'store' argument is deprecated.\n"
- "use this method with a id generator and without this."
- "argument", DeprecationWarning)
+ warnings.warn("Use of 'store' argument is deprecated.",
+ DeprecationWarning)
try:
#use _getLatestGeneratorValue here for that the technical level
#must not call the method
@@ -206,9 +203,9 @@ class IdTool(BaseTool):
else:
# Compatibility code below, in case the last version of erp5_core
# is not installed yet
- warnings.warn("You use the old version of erp5_core to generate the ids.\n"
- "please, update the business template erp5_core "
- "to have the new id generators", DeprecationWarning)
+ warnings.warn("You are using an old version of erp5_core to generate"
+ "ids.\nPlease update erp5_core business template to "
+ "use new id generators", DeprecationWarning)
new_id = None
if default is None:
default = 1
@@ -298,8 +295,8 @@ class IdTool(BaseTool):
"""
Get the last length id generated
"""
- warnings.warn('The usage of this method is deprecated.\n'
- , DeprecationWarning)
+ warnings.warn('getLastLengthGeneratedId is deprecated',
+ DeprecationWarning)
# check in persistent mapping if exists
if getattr(aq_base(self), 'dict_length_ids', None) is not None:
last_id = self.dict_length_ids.get(id_group)
@@ -331,8 +328,7 @@ class IdTool(BaseTool):
"""
Get the last id generated
"""
- warnings.warn('The usage of this method is deprecated.\n'
- , DeprecationWarning)
+ warnings.warn('getLastGeneratedId is deprecated', DeprecationWarning)
if getattr(aq_base(self), 'dict_ids', None) is None:
self.dict_ids = PersistentMapping()
last_id = None
@@ -359,11 +355,11 @@ class IdTool(BaseTool):
Generates an Id.
See generateNewLengthIdList documentation for details.
"""
- warnings.warn('The usage of this method is deprecated.\n'
- 'use directly generateNewIdList'
- ' with a id_generator sql', DeprecationWarning)
+ warnings.warn('generateNewLengthId is deprecated.\n'
+ 'Use generateNewIdList with a sql id_generator',
+ DeprecationWarning)
new_id = self.generateNewIdList(id_group=id_group,
- id_count=1, default=default, store=store)[0]
+ id_count=1, default=default, store=store)[0]
return new_id
security.declareProtected(Permissions.AccessContentsInformation,
More information about the Erp5-report
mailing list