Commit be48e678 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Rather than relying on the presense of id, use the fact that TypeError is...

Rather than relying on the presense of id, use the fact that TypeError is raised when __init__ does not take such an argument.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14421 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent caa6bce2
...@@ -2105,13 +2105,12 @@ class Base( CopyContainer, ...@@ -2105,13 +2105,12 @@ class Base( CopyContainer,
if context is None: if context is None:
# Make a copy # Make a copy
klass = self.__class__ klass = self.__class__
if getattr(klass, 'id', None): try:
# If id is defined on the class, it is usually
# the sign that this is a tool and that
# __init__ takes no id parameter
context = klass()
else:
context = klass(self.getId()) context = klass(self.getId())
except TypeError:
# If __init__ does not take the id argument, the class is probably
# a tool, and the id is fixed.
context = klass()
context.__dict__.update(self.__dict__) context.__dict__.update(self.__dict__)
# Copy REQUEST properties to self # Copy REQUEST properties to self
if REQUEST is not None: if REQUEST is not 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