Commit bf913dab authored by Jérome Perrin's avatar Jérome Perrin

fix a few typos and try to make warning messages more informative.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43794 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 6c96d04f
...@@ -117,18 +117,16 @@ class IdTool(BaseTool): ...@@ -117,18 +117,16 @@ class IdTool(BaseTool):
Generate the next id in the sequence of ids of a particular group Generate the next id in the sequence of ids of a particular group
""" """
if id_group in (None, 'None'): 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 # for compatibilty with sql data, must not use id_group as a list
if not isinstance(id_group, str): if not isinstance(id_group, str):
id_group = repr(id_group) id_group = repr(id_group)
warnings.warn('The id_group must be a string the other types ' warnings.warn('id_group must be a string, other types '
'is deprecated.', DeprecationWarning) 'are deprecated.', DeprecationWarning)
if id_generator is None: if id_generator is None:
id_generator = 'document' id_generator = 'document'
if method is not _marker: if method is not _marker:
warnings.warn("The usage of 'method' argument is deprecated.\n" warnings.warn("Use of 'method' argument is deprecated", DeprecationWarning)
"use this method with a id generator without this"
"argument", DeprecationWarning)
try: try:
#use _getLatestGeneratorValue here for that the technical level #use _getLatestGeneratorValue here for that the technical level
#must not call the method #must not call the method
...@@ -145,9 +143,9 @@ class IdTool(BaseTool): ...@@ -145,9 +143,9 @@ class IdTool(BaseTool):
else: else:
# Compatibility code below, in case the last version of erp5_core # Compatibility code below, in case the last version of erp5_core
# is not installed yet # is not installed yet
warnings.warn("You use the old version of API which is deprecated.\n" warnings.warn("You are using an old version of erp5_core to generate"
"please, update the business template erp5_core " "ids.\nPlease update erp5_core business template to "
"to use the new API", DeprecationWarning) "use new id generators", DeprecationWarning)
dict_ids = getattr(aq_base(self), 'dict_ids', None) dict_ids = getattr(aq_base(self), 'dict_ids', None)
if dict_ids is None: if dict_ids is None:
dict_ids = self.dict_ids = PersistentMapping() dict_ids = self.dict_ids = PersistentMapping()
...@@ -178,18 +176,17 @@ class IdTool(BaseTool): ...@@ -178,18 +176,17 @@ class IdTool(BaseTool):
Generate a list of next ids in the sequence of ids of a particular group Generate a list of next ids in the sequence of ids of a particular group
""" """
if id_group in (None, 'None'): 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 # for compatibilty with sql data, must not use id_group as a list
if not isinstance(id_group, str): if not isinstance(id_group, str):
id_group = repr(id_group) id_group = repr(id_group)
warnings.warn('The id_group must be a string the other types ' warnings.warn('id_group must be a string, other types '
'is deprecated.', DeprecationWarning) 'are deprecated.', DeprecationWarning)
if id_generator is None: if id_generator is None:
id_generator = 'uid' id_generator = 'uid'
if store is not _marker: if store is not _marker:
warnings.warn("The usage of 'store' argument is deprecated.\n" warnings.warn("Use of 'store' argument is deprecated.",
"use this method with a id generator and without this." DeprecationWarning)
"argument", DeprecationWarning)
try: try:
#use _getLatestGeneratorValue here for that the technical level #use _getLatestGeneratorValue here for that the technical level
#must not call the method #must not call the method
...@@ -206,9 +203,9 @@ class IdTool(BaseTool): ...@@ -206,9 +203,9 @@ class IdTool(BaseTool):
else: else:
# Compatibility code below, in case the last version of erp5_core # Compatibility code below, in case the last version of erp5_core
# is not installed yet # is not installed yet
warnings.warn("You use the old version of erp5_core to generate the ids.\n" warnings.warn("You are using an old version of erp5_core to generate"
"please, update the business template erp5_core " "ids.\nPlease update erp5_core business template to "
"to have the new id generators", DeprecationWarning) "use new id generators", DeprecationWarning)
new_id = None new_id = None
if default is None: if default is None:
default = 1 default = 1
...@@ -298,8 +295,8 @@ class IdTool(BaseTool): ...@@ -298,8 +295,8 @@ class IdTool(BaseTool):
""" """
Get the last length id generated Get the last length id generated
""" """
warnings.warn('The usage of this method is deprecated.\n' warnings.warn('getLastLengthGeneratedId is deprecated',
, DeprecationWarning) DeprecationWarning)
# check in persistent mapping if exists # check in persistent mapping if exists
if getattr(aq_base(self), 'dict_length_ids', None) is not None: if getattr(aq_base(self), 'dict_length_ids', None) is not None:
last_id = self.dict_length_ids.get(id_group) last_id = self.dict_length_ids.get(id_group)
...@@ -331,8 +328,7 @@ class IdTool(BaseTool): ...@@ -331,8 +328,7 @@ class IdTool(BaseTool):
""" """
Get the last id generated Get the last id generated
""" """
warnings.warn('The usage of this method is deprecated.\n' warnings.warn('getLastGeneratedId is deprecated', DeprecationWarning)
, DeprecationWarning)
if getattr(aq_base(self), 'dict_ids', None) is None: if getattr(aq_base(self), 'dict_ids', None) is None:
self.dict_ids = PersistentMapping() self.dict_ids = PersistentMapping()
last_id = None last_id = None
...@@ -359,11 +355,11 @@ class IdTool(BaseTool): ...@@ -359,11 +355,11 @@ class IdTool(BaseTool):
Generates an Id. Generates an Id.
See generateNewLengthIdList documentation for details. See generateNewLengthIdList documentation for details.
""" """
warnings.warn('The usage of this method is deprecated.\n' warnings.warn('generateNewLengthId is deprecated.\n'
'use directly generateNewIdList' 'Use generateNewIdList with a sql id_generator',
' with a id_generator sql', DeprecationWarning) DeprecationWarning)
new_id = self.generateNewIdList(id_group=id_group, 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 return new_id
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
......
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