Commit 94693f62 authored by Kevin Deldycke's avatar Kevin Deldycke

Don't let newTrashBin create objects with leading underscore.

Convert tabs to spaces.
Remove some log.
Remove trailing spaces.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@9227 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d849eb12
...@@ -141,21 +141,32 @@ class TrashTool(BaseTool): ...@@ -141,21 +141,32 @@ class TrashTool(BaseTool):
""" """
Create a new trash bin at upgrade of bt Create a new trash bin at upgrade of bt
""" """
# LOG('new Trash bin for', 0, bt_title)
# construct date # construct date
date = DateTime() date = DateTime()
start_date = date.strftime('%Y-%m-%d') start_date = date.strftime('%Y-%m-%d')
def getBaseTrashId():
''' A little function to get an id without leading underscore
'''
base_id = '%s' % start_date
if bt_title not in ('', None):
base_id = '%s_%s' % (bt_title, base_id)
return base_id
# generate id # generate id
trash_ids = self.objectIds() trash_ids = self.objectIds()
n = 0 n = 0
new_trash_id = bt_title+'_'+start_date new_trash_id = getBaseTrashId()
while new_trash_id in trash_ids: while new_trash_id in trash_ids:
n = n + 1 n += 1
new_trash_id = '%s_%s' %(bt_title+'_'+start_date, n) new_trash_id = '%s_%s' % (getBaseTrashId(), n)
# create trash bin # create trash bin
# LOG('creating trash bin with id', 0, new_trash_id) trashbin = self.newContent( portal_type = 'Trash Bin'
trashbin = self.newContent(portal_type='Trash Bin', id=new_trash_id, title=bt_title, start_date=start_date, causality_value=bt) , id = new_trash_id
# LOG('trash item created', 0, trashbin) , title = bt_title
, start_date = start_date
, causality_value = bt
)
return trashbin return trashbin
def getTrashBinObjectsList(self, trashbin): def getTrashBinObjectsList(self, trashbin):
......
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