Commit a5b6f8fc authored by Julien Muchembled's avatar Julien Muchembled

Fix checking id of new temp objects

This fixes TestERP5Type.test_03_NewTempObject

Note this condition is useless for non-temporary objects,
because that _setObject already does many checks.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@41154 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 4cc02a13
...@@ -126,7 +126,9 @@ class FolderMixIn(ExtensionClass.Base): ...@@ -126,7 +126,9 @@ class FolderMixIn(ExtensionClass.Base):
# The only case where the id is unused (because the new object is not added # The only case where the id is unused (because the new object is not added
# to its parent) is when a temp object is created inside a non-temp object. # to its parent) is when a temp object is created inside a non-temp object.
if id is None and (temp_container or not temp_object): if id is '':
new_id = id
elif id is None and (temp_container or not temp_object):
new_id_kw = {} new_id_kw = {}
if method is not None: if method is not None:
new_id_kw['method'] = method new_id_kw['method'] = method
......
...@@ -336,9 +336,6 @@ class ERP5TypeInformation(XMLObject, ...@@ -336,9 +336,6 @@ class ERP5TypeInformation(XMLObject,
Call the init_script for the portal_type. Call the init_script for the portal_type.
Returns the object. Returns the object.
""" """
if id is None or len(id) == 0:
raise ValueError("invalid object id")
if not temp_object and not self.isConstructionAllowed(container): if not temp_object and not self.isConstructionAllowed(container):
raise AccessControl_Unauthorized('Cannot create %s' % self.getId()) raise AccessControl_Unauthorized('Cannot create %s' % self.getId())
...@@ -349,6 +346,8 @@ class ERP5TypeInformation(XMLObject, ...@@ -349,6 +346,8 @@ class ERP5TypeInformation(XMLObject,
ob = klass(id) ob = klass(id)
if temp_object: if temp_object:
if id in (None, ''):
raise ValueError("invalid object id")
ob = ob.__of__(container) ob = ob.__of__(container)
for ignore in ('activate_kw', 'is_indexable', 'reindex_kw'): for ignore in ('activate_kw', 'is_indexable', 'reindex_kw'):
kw.pop(ignore, None) kw.pop(ignore, None)
......
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