Commit 414cedc3 authored by Jérome Perrin's avatar Jérome Perrin

use isinstance instead of type(); fix indentation

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@6932 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 852ef34e
...@@ -78,7 +78,7 @@ class FolderMixIn(ExtensionClass.Base, CopyContainer): ...@@ -78,7 +78,7 @@ class FolderMixIn(ExtensionClass.Base, CopyContainer):
default=default, method=method)) default=default, method=method))
else: else:
new_id = str(id) new_id = str(id)
if portal_type is None: if portal_type is None:
# XXX This feature is very confusing # XXX This feature is very confusing
# And made the code more difficult to update # And made the code more difficult to update
portal_type = container.allowedContentTypes()[0].id portal_type = container.allowedContentTypes()[0].id
...@@ -104,9 +104,9 @@ class FolderMixIn(ExtensionClass.Base, CopyContainer): ...@@ -104,9 +104,9 @@ class FolderMixIn(ExtensionClass.Base, CopyContainer):
""" delete items in this folder. """ delete items in this folder.
`id` can be a list or a string. `id` can be a list or a string.
""" """
if type(id) is type(''): if isinstance(id, str):
self._delObject(id) self._delObject(id)
elif type(id) is type([]) or type(id) is type(()): elif isinstance(id, list) or isinstance(id, tuple):
for my_id in id: for my_id in id:
self._delObject(my_id) self._delObject(my_id)
else: else:
...@@ -116,32 +116,30 @@ class FolderMixIn(ExtensionClass.Base, CopyContainer): ...@@ -116,32 +116,30 @@ class FolderMixIn(ExtensionClass.Base, CopyContainer):
# Automatic ID Generation method # Automatic ID Generation method
security.declareProtected(Permissions.View, 'generateNewId') security.declareProtected(Permissions.View, 'generateNewId')
def generateNewId(self,id_group=None,default=None,method=None): def generateNewId(self,id_group=None,default=None,method=None):
""" """
Generate a new Id which has not been taken yet in this folder. Generate a new Id which has not been taken yet in this folder.
Eventually increment the id number until an available id Eventually increment the id number until an available id
can be found can be found
Permission is view because we may want to add content to a folder Permission is view because we may want to add content to a folder
without changing the folder content itself. XXXXXXXXXXX without changing the folder content itself. XXXXXXXXXXX
XXXXXXXXXXXX XXXXXXXXXXXX
""" """
my_id = None my_id = None
if id_group is None: if id_group is None:
id_group = self.getIdGroup() id_group = self.getIdGroup()
if id_group is None or id_group=='None': if id_group is None or id_group=='None':
try: try:
my_id = int(self.getLastId()) my_id = int(self.getLastId())
except TypeError: except TypeError:
my_id = 1 my_id = 1
while self.hasContent(str(my_id)): while self.hasContent(str(my_id)):
my_id = my_id + 1 my_id = my_id + 1
#LOG('_setLastId', 0, str(self)) self._setLastId(str(my_id)) # Make sure no reindexing happens
#LOG('_setLastId', 0, str(self.aq_base)) else:
self._setLastId(str(my_id)) # Make sure no reindexing happens my_id = self.portal_ids.generateNewId(id_group=id_group,default=default,method=method)
else:
my_id = self.portal_ids.generateNewId(id_group=id_group,default=default,method=method)
return str(my_id) return str(my_id)
security.declareProtected(Permissions.View, 'hasContent') security.declareProtected(Permissions.View, 'hasContent')
def hasContent(self,id): def hasContent(self,id):
......
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