[Erp5-report] r40200 nicolas.dumazet - /erp5/trunk/products/ERP5Type/dynamic/

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Nov 11 03:07:07 CET 2010


Author: nicolas.dumazet
Date: Thu Nov 11 03:07:06 2010
New Revision: 40200

URL: http://svn.erp5.org?rev=40200&view=rev
Log:
Be more permissive if neither factory_method_id nor type_class are set.

We already try to infer/guess the Document type if portal type object does not
exist: it's logical to do the same if portal type exists but is misconfigured,
or just way too old.

Modified:
    erp5/trunk/products/ERP5Type/dynamic/portal_type_class.py

Modified: erp5/trunk/products/ERP5Type/dynamic/portal_type_class.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/dynamic/portal_type_class.py?rev=40200&r1=40199&r2=40200&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/dynamic/portal_type_class.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/dynamic/portal_type_class.py [utf8] Thu Nov 11 03:07:06 2010
@@ -104,11 +104,22 @@ def generatePortalTypeClass(portal_type_
   site = getSite()
 
   accessor_holder_list = []
+  type_class = None
 
   # Do not use __getitem__ (or _getOb) because portal_type may exist in a
   # type provider other than Types Tool.
   portal_type = getattr(site.portal_types, portal_type_name, None)
-  if portal_type is None:
+  if portal_type is not None:
+    # type_class has a compatibility getter that should return
+    # something even if the field is not set (i.e. Base Type object
+    # was not migrated yet). It only works if factory_method_id is set.
+    type_class = portal_type.getTypeClass()
+    mixin_list = portal_type.getTypeMixinList()
+    interface_list = portal_type.getTypeInterfaceList()
+
+  # But if neither factory_init_method_id nor type_class are set on
+  # the portal type, we have to try to guess, for compatibility
+  if type_class is None:
     # Try to figure out a coresponding document class from the document side.
     # This can happen when calling newTempAmount for instance:
     #  Amount has no corresponding Base Type and will never have one
@@ -117,13 +128,6 @@ def generatePortalTypeClass(portal_type_
     type_class = portal_type_name.replace(' ', '')
     mixin_list = []
     interface_list = []
-  else:
-    # type_class has a compatibility getter that should return
-    # something even if the field is not set (i.e. Base Type object
-    # was not migrated yet)
-    type_class = portal_type.getTypeClass()
-    mixin_list = portal_type.getTypeMixinList()
-    interface_list = portal_type.getTypeInterfaceList()
 
   type_class_path = document_class_registry.get(type_class)
   if type_class_path is None:




More information about the Erp5-report mailing list