[Erp5-report] r38756 nicolas.dumazet - /erp5/trunk/products/ERP5Type/Utils.py

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Sep 29 16:17:57 CEST 2010


Author: nicolas.dumazet
Date: Wed Sep 29 16:17:57 2010
New Revision: 38756

URL: http://svn.erp5.org?rev=38756&view=rev
Log:
fill correctly document_class_registry and mixin_class_registry

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

Modified: erp5/trunk/products/ERP5Type/Utils.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Utils.py?rev=38756&r1=38755&r2=38756&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Utils.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Utils.py [utf8] Wed Sep 29 16:17:57 2010
@@ -470,15 +470,21 @@ def updateGlobals(this_module, global_ho
     for module_id in module_id_list:
       import_method(module_id, path=path, is_erp5_type=is_erp5_type)
 
+  from Products.ERP5Type import document_class_registry
+  module_name = this_module.__name__
   # Return core document_class list (for ERP5Type only)
   # this was introduced to permit overriding ERP5Type Document classes
   # which was not possible when they were define in the Document folder
   path, core_module_id_list = getModuleIdList(product_path, 'Core')
   for document in core_module_id_list:
+    module_path = '.'.join((module_name, 'Core', document, document))
+    document_class_registry[document] = module_path
     InitializeDocument(document, document_path=path)
   # Return document_class list
   path, module_id_list = getModuleIdList(product_path, 'Document')
   for document in module_id_list:
+    module_path = '.'.join((module_name, 'Document', document, document))
+    document_class_registry[document] = module_path
     InitializeDocument(document, document_path=path)
 
   # Return interactor_class list
@@ -895,6 +901,10 @@ def writeLocalDocument(class_id, text, c
   module = imp.load_source(class_id, path)
   getattr(module, class_id)
 
+  # and register correctly the new document
+  from Products.ERP5Type import document_class_registry
+  document_class_registry[class_id] = "%s.%s" % (module.__name__, class_id)
+
 def setDefaultClassProperties(property_holder):
   """Initialize default properties for ERP5Type Documents.
   """
@@ -1100,7 +1110,27 @@ def initializeProduct( context,
     This function does all the initialization steps required
     for a Zope / CMF Product
   """
-  product_name = this_module.__name__.split('.')[-1]
+  module_name = this_module.__name__
+
+  from Products.ERP5Type import document_class_registry
+  # Content classes are exceptions and should be registered here.
+  # other products were all already registered in updateGlobals()
+  # because getModuleIdList works fine for Document/ and Core/
+  for klass in content_classes:
+    n = klass.__name__
+    document_class_registry[n] = "%s.%s" % (klass.__module__, n)
+
+  mixin_module = getattr(this_module, 'mixin', None)
+  if mixin_module is not None:
+    from Products.ERP5Type import mixin_class_registry
+    for k, submodule in inspect.getmembers(mixin_module, inspect.ismodule):
+      for klassname, klass in inspect.getmembers(submodule, inspect.isclass):
+        # only classes defined here
+        if 'mixin' in klass.__module__ and not issubclass(klass, Exception):
+          classpath = '.'.join((module_name, 'mixin', k, klassname))
+          mixin_class_registry[klassname] = classpath
+
+  product_name = module_name.split('.')[-1]
 
   # Define content constructors for Document content classes (RAD)
   initializeDefaultConstructors(content_classes)




More information about the Erp5-report mailing list