Commit c812c01f authored by Sebastien Robin's avatar Sebastien Robin

- rename method_id attribute to __name__ in order to make

  FolderMethodWrapper compatible with WorkflowMethods
- use random ids for _generatePerDayId


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@16410 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 17e42f54
...@@ -166,15 +166,10 @@ class FolderMixIn(ExtensionClass.Base): ...@@ -166,15 +166,10 @@ class FolderMixIn(ExtensionClass.Base):
def _generatePerDayId(self): def _generatePerDayId(self):
""" """
Generate id base on date, useful for HBTreeFolder Generate id base on date, useful for HBTreeFolder
We also append random id
""" """
current_date = str(DateTime().Date()).replace("/", "") current_date = str(DateTime().Date()).replace("/", "")
try: my_id = self._generateRandomId()
my_id = int(self.getLastId())
except TypeError:
my_id = 1
while self.hasContent("%s-%s" %(current_date, my_id)):
my_id = my_id + 1
my_id = str(my_id)
self._setLastId(my_id) # Make sure no reindexing happens self._setLastId(my_id) # Make sure no reindexing happens
return "%s-%s" %(current_date, my_id) return "%s-%s" %(current_date, my_id)
...@@ -339,7 +334,7 @@ class FolderMethodWrapper(Method): ...@@ -339,7 +334,7 @@ class FolderMethodWrapper(Method):
This a wrapper between folder method and folder type method This a wrapper between folder method and folder type method
""" """
def __init__(self, method_id): def __init__(self, method_id):
self.method_id = method_id self.__name__ = method_id
def __call__(self, folder, *args, **kw): def __call__(self, folder, *args, **kw):
folder_handler = getattr(folder, '_folder_handler', None) folder_handler = getattr(folder, '_folder_handler', None)
...@@ -349,7 +344,8 @@ class FolderMethodWrapper(Method): ...@@ -349,7 +344,8 @@ class FolderMethodWrapper(Method):
folder.initializeFolderHandler() folder.initializeFolderHandler()
folder_handler = getattr(folder, '_folder_handler', None) folder_handler = getattr(folder, '_folder_handler', None)
handler = folder_handler_dict.get(folder_handler,None) handler = folder_handler_dict.get(folder_handler,None)
return getattr(handler, self.method_id)(folder, *args, **kw) return getattr(handler, self.__name__)(folder, *args, **kw)
class FolderHandler: class FolderHandler:
......
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