[Erp5-report] r14421 - /erp5/trunk/products/ERP5Type/Base.py

nobody at svn.erp5.org nobody at svn.erp5.org
Tue May 8 01:59:30 CEST 2007


Author: yo
Date: Tue May  8 01:59:30 2007
New Revision: 14421

URL: http://svn.erp5.org?rev=14421&view=rev
Log:
Rather than relying on the presense of id, use the fact that TypeError is raised when __init__ does not take such an argument.

Modified:
    erp5/trunk/products/ERP5Type/Base.py

Modified: erp5/trunk/products/ERP5Type/Base.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Base.py?rev=14421&r1=14420&r2=14421&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Base.py (original)
+++ erp5/trunk/products/ERP5Type/Base.py Tue May  8 01:59:30 2007
@@ -2105,13 +2105,12 @@
     if context is None:
       # Make a copy
       klass = self.__class__
-      if getattr(klass, 'id', None):
-        # If id is defined on the class, it is usually
-        # the sign that this is a tool and that
-        # __init__ takes no id parameter
+      try:
+        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()
-      else:
-        context = klass(self.getId())
       context.__dict__.update(self.__dict__)
       # Copy REQUEST properties to self
       if REQUEST is not None:




More information about the Erp5-report mailing list