From 967f765227c4723dcb3670a00dd0111f10894f21 Mon Sep 17 00:00:00 2001
From: Nicolas Dumazet <nicolas.dumazet@nexedi.com>
Date: Tue, 18 Jan 2011 05:36:05 +0000
Subject: [PATCH] put dynamic module registration in initializeProduct to avoid
 depending on any kind of initialization order

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@42393 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Type/Utils.py    | 9 +++++++++
 product/ERP5Type/__init__.py | 3 ---
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/product/ERP5Type/Utils.py b/product/ERP5Type/Utils.py
index dd3b50c16d..81b27d7708 100644
--- a/product/ERP5Type/Utils.py
+++ b/product/ERP5Type/Utils.py
@@ -1102,6 +1102,15 @@ def initializeProduct( context,
   except:
     LOG("ERP5Type", BLATHER, "No help directory for %s" % product_name)
 
+  # create dynamic modules if they dont exist, this only ever happens
+  # once.
+  try:
+    import erp5.portal_type
+  except ImportError:
+    from dynamic.portal_type_class import initializeDynamicModules
+    initializeDynamicModules()
+    import erp5.portal_type
+
   # Tools initialization
   tools = portal_tools
   if len(tools) > 0:
diff --git a/product/ERP5Type/__init__.py b/product/ERP5Type/__init__.py
index 3f0cf07cb4..2e062b1ee9 100644
--- a/product/ERP5Type/__init__.py
+++ b/product/ERP5Type/__init__.py
@@ -114,9 +114,6 @@ def initialize( context ):
                          content_constructors = content_constructors,
                          content_classes = content_classes)
 
-  from dynamic.portal_type_class import initializeDynamicModules
-  initializeDynamicModules()
-
   # Register our Workflow factories directly (if on CMF 2)
   Products.ERP5Type.Workflow.registerAllWorkflowFactories(context)
   # We should register local constraints at some point
-- 
2.30.9