From d1a0f4aae6a4dd6c6f3596b7cd39bb7a294c8b7d Mon Sep 17 00:00:00 2001
From: Jean-Paul Smets <jp@nexedi.com>
Date: Thu, 5 Aug 2004 10:45:26 +0000
Subject: [PATCH] updated for aq_dynamic code generation

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@1317 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/CMFActivity/Constraint/.cvsignore     |   1 -
 product/CMFActivity/Constraint/__init__.py    |   0
 product/CMFActivity/Document/.cvsignore       |   1 -
 product/CMFActivity/Document/__init__.py      |   0
 product/CMFActivity/Interface/.cvsignore      |   1 -
 product/CMFActivity/Interface/__init__.py     |   0
 product/CMFActivity/PropertySheet/.cvsignore  |   1 -
 product/CMFActivity/PropertySheet/__init__.py |   0
 product/CMFActivity/__init__.py               |  11 +-
 product/CMFCategory/Document/.cvsignore       |   1 -
 product/CMFCategory/Document/__init__.py      |   0
 product/CMFCategory/Interface/.cvsignore      |   1 -
 product/CMFCategory/Interface/__init__.py     |   0
 product/CMFCategory/PropertySheet/.cvsignore  |   1 -
 product/CMFCategory/PropertySheet/__init__.py |   2 -
 product/CMFCategory/__init__.py               |  17 +-
 product/Coramy/Constraint/.cvsignore          |   1 -
 product/Coramy/Constraint/__init__.py         |   0
 product/Coramy/Document/.cvsignore            |   1 -
 product/Coramy/Document/__init__.py           |   0
 product/Coramy/PropertySheet/.cvsignore       |   1 -
 product/Coramy/PropertySheet/__init__.py      |   0
 product/Coramy/__init__.py                    |  17 +-
 product/ERP5/Constraint/.cvsignore            |   1 -
 product/ERP5/Constraint/__init__.py           |   0
 product/ERP5/Document/.cvsignore              |   1 -
 product/ERP5/Document/__init__.py             |   0
 product/ERP5/Interface/__init__.py            |   4 -
 product/ERP5/PropertySheet/.cvsignore         |   1 -
 product/ERP5/PropertySheet/__init__.py        |   0
 product/ERP5/__init__.py                      |  22 +--
 product/ERP5Catalog/Constraint/.cvsignore     |   1 -
 product/ERP5Catalog/Constraint/__init__.py    |   0
 product/ERP5Catalog/Document/.cvsignore       |   1 -
 product/ERP5Catalog/Document/__init__.py      |   0
 product/ERP5Catalog/Interface/.cvsignore      |   1 -
 product/ERP5Catalog/Interface/__init__.py     |   0
 product/ERP5Catalog/PropertySheet/.cvsignore  |   1 -
 product/ERP5Catalog/PropertySheet/__init__.py |   0
 product/ERP5Catalog/__init__.py               |  11 +-
 product/ERP5Compatibility/__init__.py         |   1 +
 product/ERP5Form/Constraint/.cvsignore        |   1 -
 product/ERP5Form/Constraint/__init__.py       |   0
 product/ERP5Form/Document/.cvsignore          |   1 -
 product/ERP5Form/Document/__init__.py         |   0
 product/ERP5Form/Interface/.cvsignore         |   1 -
 product/ERP5Form/Interface/__init__.py        |   0
 product/ERP5Form/PropertySheet/.cvsignore     |   1 -
 product/ERP5Form/PropertySheet/__init__.py    |   0
 product/ERP5Form/__init__.py                  |  14 +-
 product/ERP5Shop/Constraint/.cvsignore        |   1 -
 product/ERP5Shop/Constraint/__init__.py       |   0
 product/ERP5Shop/Document/.cvsignore          |   1 -
 product/ERP5Shop/Document/__init__.py         |   0
 product/ERP5Shop/Interface/.cvsignore         |   1 -
 product/ERP5Shop/Interface/__init__.py        |   0
 product/ERP5Shop/PropertySheet/.cvsignore     |   1 -
 product/ERP5Shop/PropertySheet/__init__.py    |   0
 product/ERP5Shop/__init__.py                  |  17 +-
 product/ERP5SyncML/Constraint/.cvsignore      |   1 -
 product/ERP5SyncML/Constraint/__init__.py     |   0
 product/ERP5SyncML/Document/.cvsignore        |   1 -
 product/ERP5SyncML/Document/__init__.py       |   0
 product/ERP5SyncML/Interface/.cvsignore       |   1 -
 product/ERP5SyncML/Interface/__init__.py      |   0
 product/ERP5SyncML/PropertySheet/.cvsignore   |   1 -
 product/ERP5SyncML/PropertySheet/__init__.py  |   0
 product/ERP5SyncML/__init__.py                |  19 +-
 product/ERP5Type/Base.py                      |  21 ++-
 product/ERP5Type/InitGenerator.py             | 164 +-----------------
 product/ERP5Type/PropertySheet/__init__.py    |   6 +-
 product/ERP5Type/Utils.py                     | 146 ++++++++++------
 product/ERP5Type/__init__.py                  |  30 ++--
 product/Nexedi/Constraint/.cvsignore          |   1 -
 product/Nexedi/Constraint/__init__.py         |   0
 product/Nexedi/Document/.cvsignore            |   1 -
 product/Nexedi/Document/__init__.py           |   0
 product/Nexedi/Interface/.cvsignore           |   1 -
 product/Nexedi/Interface/__init__.py          |   0
 product/Nexedi/PropertySheet/.cvsignore       |   1 -
 product/Nexedi/PropertySheet/__init__.py      |   0
 product/Nexedi/__init__.py                    |  17 +-
 82 files changed, 163 insertions(+), 389 deletions(-)
 create mode 100755 product/CMFActivity/Constraint/__init__.py
 create mode 100755 product/CMFActivity/Document/__init__.py
 create mode 100755 product/CMFActivity/Interface/__init__.py
 create mode 100755 product/CMFActivity/PropertySheet/__init__.py
 create mode 100755 product/CMFCategory/Document/__init__.py
 create mode 100755 product/CMFCategory/Interface/__init__.py
 create mode 100755 product/Coramy/Constraint/__init__.py
 create mode 100755 product/Coramy/Document/__init__.py
 create mode 100755 product/Coramy/PropertySheet/__init__.py
 create mode 100755 product/ERP5/Constraint/__init__.py
 create mode 100755 product/ERP5/Document/__init__.py
 create mode 100755 product/ERP5/PropertySheet/__init__.py
 create mode 100755 product/ERP5Catalog/Constraint/__init__.py
 create mode 100755 product/ERP5Catalog/Document/__init__.py
 create mode 100755 product/ERP5Catalog/Interface/__init__.py
 create mode 100755 product/ERP5Catalog/PropertySheet/__init__.py
 create mode 100755 product/ERP5Form/Constraint/__init__.py
 create mode 100755 product/ERP5Form/Document/__init__.py
 create mode 100755 product/ERP5Form/Interface/__init__.py
 create mode 100755 product/ERP5Form/PropertySheet/__init__.py
 create mode 100755 product/ERP5Shop/Constraint/__init__.py
 create mode 100755 product/ERP5Shop/Document/__init__.py
 create mode 100755 product/ERP5Shop/Interface/__init__.py
 create mode 100755 product/ERP5Shop/PropertySheet/__init__.py
 create mode 100755 product/ERP5SyncML/Constraint/__init__.py
 create mode 100755 product/ERP5SyncML/Document/__init__.py
 create mode 100755 product/ERP5SyncML/Interface/__init__.py
 create mode 100755 product/ERP5SyncML/PropertySheet/__init__.py
 create mode 100755 product/Nexedi/Constraint/__init__.py
 create mode 100755 product/Nexedi/Document/__init__.py
 create mode 100755 product/Nexedi/Interface/__init__.py
 create mode 100755 product/Nexedi/PropertySheet/__init__.py

diff --git a/product/CMFActivity/Constraint/.cvsignore b/product/CMFActivity/Constraint/.cvsignore
index 432ed787d1..d0743b7da6 100755
--- a/product/CMFActivity/Constraint/.cvsignore
+++ b/product/CMFActivity/Constraint/.cvsignore
@@ -1,3 +1,2 @@
 .AppleDouble
 *.pyc
-__init__.py
diff --git a/product/CMFActivity/Constraint/__init__.py b/product/CMFActivity/Constraint/__init__.py
new file mode 100755
index 0000000000..e69de29bb2
diff --git a/product/CMFActivity/Document/.cvsignore b/product/CMFActivity/Document/.cvsignore
index 432ed787d1..d0743b7da6 100755
--- a/product/CMFActivity/Document/.cvsignore
+++ b/product/CMFActivity/Document/.cvsignore
@@ -1,3 +1,2 @@
 .AppleDouble
 *.pyc
-__init__.py
diff --git a/product/CMFActivity/Document/__init__.py b/product/CMFActivity/Document/__init__.py
new file mode 100755
index 0000000000..e69de29bb2
diff --git a/product/CMFActivity/Interface/.cvsignore b/product/CMFActivity/Interface/.cvsignore
index 432ed787d1..d0743b7da6 100755
--- a/product/CMFActivity/Interface/.cvsignore
+++ b/product/CMFActivity/Interface/.cvsignore
@@ -1,3 +1,2 @@
 .AppleDouble
 *.pyc
-__init__.py
diff --git a/product/CMFActivity/Interface/__init__.py b/product/CMFActivity/Interface/__init__.py
new file mode 100755
index 0000000000..e69de29bb2
diff --git a/product/CMFActivity/PropertySheet/.cvsignore b/product/CMFActivity/PropertySheet/.cvsignore
index 432ed787d1..d0743b7da6 100755
--- a/product/CMFActivity/PropertySheet/.cvsignore
+++ b/product/CMFActivity/PropertySheet/.cvsignore
@@ -1,3 +1,2 @@
 .AppleDouble
 *.pyc
-__init__.py
diff --git a/product/CMFActivity/PropertySheet/__init__.py b/product/CMFActivity/PropertySheet/__init__.py
new file mode 100755
index 0000000000..e69de29bb2
diff --git a/product/CMFActivity/__init__.py b/product/CMFActivity/__init__.py
index a5caf61c15..087cba0445 100755
--- a/product/CMFActivity/__init__.py
+++ b/product/CMFActivity/__init__.py
@@ -30,16 +30,11 @@
     and extended local roles management
 """
 
-# First import the minimal number of packages required by the code generation
-from Products.ERP5Type.InitGenerator import generateInitFiles
-import sys
-
-# Update the self generated code for Document, PropertySheet and Interface
-this_module = sys.modules[ __name__ ]
-document_classes = generateInitFiles(this_module, globals())
-
 # Update ERP5 Globals
 from Products.ERP5Type.Utils import initializeProduct, updateGlobals
+import sys, Permissions
+this_module = sys.modules[ __name__ ]
+document_classes = updateGlobals( this_module, globals(), permissions_module = Permissions)
 
 # Finish installation
 def initialize( context ):
diff --git a/product/CMFCategory/Document/.cvsignore b/product/CMFCategory/Document/.cvsignore
index 654a6adb18..d0743b7da6 100755
--- a/product/CMFCategory/Document/.cvsignore
+++ b/product/CMFCategory/Document/.cvsignore
@@ -1,3 +1,2 @@
-__init__.py
 .AppleDouble
 *.pyc
diff --git a/product/CMFCategory/Document/__init__.py b/product/CMFCategory/Document/__init__.py
new file mode 100755
index 0000000000..e69de29bb2
diff --git a/product/CMFCategory/Interface/.cvsignore b/product/CMFCategory/Interface/.cvsignore
index 654a6adb18..d0743b7da6 100755
--- a/product/CMFCategory/Interface/.cvsignore
+++ b/product/CMFCategory/Interface/.cvsignore
@@ -1,3 +1,2 @@
-__init__.py
 .AppleDouble
 *.pyc
diff --git a/product/CMFCategory/Interface/__init__.py b/product/CMFCategory/Interface/__init__.py
new file mode 100755
index 0000000000..e69de29bb2
diff --git a/product/CMFCategory/PropertySheet/.cvsignore b/product/CMFCategory/PropertySheet/.cvsignore
index 654a6adb18..d0743b7da6 100755
--- a/product/CMFCategory/PropertySheet/.cvsignore
+++ b/product/CMFCategory/PropertySheet/.cvsignore
@@ -1,3 +1,2 @@
-__init__.py
 .AppleDouble
 *.pyc
diff --git a/product/CMFCategory/PropertySheet/__init__.py b/product/CMFCategory/PropertySheet/__init__.py
index 6653b5cedf..e69de29bb2 100755
--- a/product/CMFCategory/PropertySheet/__init__.py
+++ b/product/CMFCategory/PropertySheet/__init__.py
@@ -1,2 +0,0 @@
-from CategoryCore import CategoryCore
-from BaseCategory import BaseCategory
\ No newline at end of file
diff --git a/product/CMFCategory/__init__.py b/product/CMFCategory/__init__.py
index 9d4b78e36d..31222b2731 100755
--- a/product/CMFCategory/__init__.py
+++ b/product/CMFCategory/__init__.py
@@ -30,22 +30,11 @@
     in the CMF. It is based on the ERP5Type RAD
 """
 
-# First import the minimal number of packages required by the code generation
-from Products.ERP5Type.InitGenerator import generateInitFiles
-import sys
-
-# Update the self generated code for Document, PropertySheet and Interface
-this_module = sys.modules[ __name__ ]
-document_classes = generateInitFiles(this_module, globals())
-
 # Update ERP5 Globals
 from Products.ERP5Type.Utils import initializeProduct, updateGlobals
-import Interface, PropertySheet, Permissions, Constraint
-updateGlobals( this_module, globals(),
-               property_sheet_module = PropertySheet,
-               interface_module = Interface,
-               permissions_module = Permissions,
-               constraint_module = Constraint)
+import sys, Permissions
+this_module = sys.modules[ __name__ ]
+document_classes = updateGlobals( this_module, globals(), permissions_module = Permissions)
 
 # Define object classes and tools
 import Category, CategoryTool
diff --git a/product/Coramy/Constraint/.cvsignore b/product/Coramy/Constraint/.cvsignore
index 654a6adb18..d0743b7da6 100755
--- a/product/Coramy/Constraint/.cvsignore
+++ b/product/Coramy/Constraint/.cvsignore
@@ -1,3 +1,2 @@
-__init__.py
 .AppleDouble
 *.pyc
diff --git a/product/Coramy/Constraint/__init__.py b/product/Coramy/Constraint/__init__.py
new file mode 100755
index 0000000000..e69de29bb2
diff --git a/product/Coramy/Document/.cvsignore b/product/Coramy/Document/.cvsignore
index 432ed787d1..d0743b7da6 100755
--- a/product/Coramy/Document/.cvsignore
+++ b/product/Coramy/Document/.cvsignore
@@ -1,3 +1,2 @@
 .AppleDouble
 *.pyc
-__init__.py
diff --git a/product/Coramy/Document/__init__.py b/product/Coramy/Document/__init__.py
new file mode 100755
index 0000000000..e69de29bb2
diff --git a/product/Coramy/PropertySheet/.cvsignore b/product/Coramy/PropertySheet/.cvsignore
index 432ed787d1..d0743b7da6 100755
--- a/product/Coramy/PropertySheet/.cvsignore
+++ b/product/Coramy/PropertySheet/.cvsignore
@@ -1,3 +1,2 @@
 .AppleDouble
 *.pyc
-__init__.py
diff --git a/product/Coramy/PropertySheet/__init__.py b/product/Coramy/PropertySheet/__init__.py
new file mode 100755
index 0000000000..e69de29bb2
diff --git a/product/Coramy/__init__.py b/product/Coramy/__init__.py
index 69b951edb4..726156cfdd 100755
--- a/product/Coramy/__init__.py
+++ b/product/Coramy/__init__.py
@@ -29,22 +29,11 @@
     ERP5 Free Software ERP
 """
 
-# First import the minimal number of packages required by the code generation
-from Products.ERP5Type.InitGenerator import generateInitFiles
-import sys
-
-# Update the self generated code for Document, PropertySheet and Interface
-this_module = sys.modules[ __name__ ]
-document_classes = generateInitFiles(this_module, globals())
-
 # Update ERP5 Globals
 from Products.ERP5Type.Utils import initializeProduct, updateGlobals
-import Interface, PropertySheet, Permissions, Constraint
-updateGlobals( this_module, globals(),
-                   property_sheet_module = PropertySheet,
-                   interface_module = Interface,
-                   permissions_module = Permissions,
-                   constraint_module = Constraint)
+import sys, Permissions
+this_module = sys.modules[ __name__ ]
+document_classes = updateGlobals( this_module, globals(), permissions_module = Permissions)
 
 # Define object classes and tools
 object_classes = ()
diff --git a/product/ERP5/Constraint/.cvsignore b/product/ERP5/Constraint/.cvsignore
index 654a6adb18..d0743b7da6 100755
--- a/product/ERP5/Constraint/.cvsignore
+++ b/product/ERP5/Constraint/.cvsignore
@@ -1,3 +1,2 @@
-__init__.py
 .AppleDouble
 *.pyc
diff --git a/product/ERP5/Constraint/__init__.py b/product/ERP5/Constraint/__init__.py
new file mode 100755
index 0000000000..e69de29bb2
diff --git a/product/ERP5/Document/.cvsignore b/product/ERP5/Document/.cvsignore
index 432ed787d1..d0743b7da6 100755
--- a/product/ERP5/Document/.cvsignore
+++ b/product/ERP5/Document/.cvsignore
@@ -1,3 +1,2 @@
 .AppleDouble
 *.pyc
-__init__.py
diff --git a/product/ERP5/Document/__init__.py b/product/ERP5/Document/__init__.py
new file mode 100755
index 0000000000..e69de29bb2
diff --git a/product/ERP5/Interface/__init__.py b/product/ERP5/Interface/__init__.py
index 5d88c12593..e69de29bb2 100755
--- a/product/ERP5/Interface/__init__.py
+++ b/product/ERP5/Interface/__init__.py
@@ -1,4 +0,0 @@
-from Coordinate import Coordinate
-from Entity import Entity
-from Predicate import Predicate
-from Variated import Variated
\ No newline at end of file
diff --git a/product/ERP5/PropertySheet/.cvsignore b/product/ERP5/PropertySheet/.cvsignore
index 432ed787d1..d0743b7da6 100755
--- a/product/ERP5/PropertySheet/.cvsignore
+++ b/product/ERP5/PropertySheet/.cvsignore
@@ -1,3 +1,2 @@
 .AppleDouble
 *.pyc
-__init__.py
diff --git a/product/ERP5/PropertySheet/__init__.py b/product/ERP5/PropertySheet/__init__.py
new file mode 100755
index 0000000000..e69de29bb2
diff --git a/product/ERP5/__init__.py b/product/ERP5/__init__.py
index 8e961e55d6..de28b82565 100755
--- a/product/ERP5/__init__.py
+++ b/product/ERP5/__init__.py
@@ -29,25 +29,14 @@
     ERP5 Free Software ERP
 """
 
-# First import the minimal number of packages required by the code generation
-from Products.ERP5Type.InitGenerator import generateInitFiles
-import sys
-
-# Update the self generated code for Document, PropertySheet and Interface
-this_module = sys.modules[ __name__ ]
-document_classes = generateInitFiles(this_module, globals())
-
 # Update ERP5 Globals
 from Products.ERP5Type.Utils import initializeProduct, updateGlobals
-import Interface, PropertySheet, Permissions, Constraint
-updateGlobals( this_module, globals(),
-                   property_sheet_module = PropertySheet,
-                   interface_module = Interface,
-                   permissions_module = Permissions,
-                   constraint_module = Constraint)
+import sys, Permissions
+this_module = sys.modules[ __name__ ]
+document_classes = updateGlobals( this_module, globals(), permissions_module = Permissions)
 
 # Define object classes and tools
-from Tool import Category, CategoryTool, SimulationTool, RuleTool, IdTool, TemplateTool, TestTool
+from Tool import Category, CategoryTool, SimulationTool, RuleTool, IdTool, TemplateTool, TestTool, DomainTool
 import ERP5Site
 object_classes = ( Category.Category,
                    Category.BaseCategory,
@@ -58,6 +47,7 @@ portal_tools = ( CategoryTool.CategoryTool,
                  RuleTool.RuleTool,
                  IdTool.IdTool,
                  TemplateTool.TemplateTool,
+                 DomainTool.DomainTool,
                  TestTool.TestTool
                 )
 content_classes = ()
@@ -69,6 +59,8 @@ from InteractionWorkflow import InteractionWorkflowDefinition
 # Finish installation
 def initialize( context ):
   import Document
+  from zLOG import LOG
+  LOG('In ERP5 initialize', 0, '')
   initializeProduct(context, this_module, globals(),
                          document_module = Document,
                          document_classes = document_classes,
diff --git a/product/ERP5Catalog/Constraint/.cvsignore b/product/ERP5Catalog/Constraint/.cvsignore
index 432ed787d1..d0743b7da6 100755
--- a/product/ERP5Catalog/Constraint/.cvsignore
+++ b/product/ERP5Catalog/Constraint/.cvsignore
@@ -1,3 +1,2 @@
 .AppleDouble
 *.pyc
-__init__.py
diff --git a/product/ERP5Catalog/Constraint/__init__.py b/product/ERP5Catalog/Constraint/__init__.py
new file mode 100755
index 0000000000..e69de29bb2
diff --git a/product/ERP5Catalog/Document/.cvsignore b/product/ERP5Catalog/Document/.cvsignore
index 432ed787d1..d0743b7da6 100755
--- a/product/ERP5Catalog/Document/.cvsignore
+++ b/product/ERP5Catalog/Document/.cvsignore
@@ -1,3 +1,2 @@
 .AppleDouble
 *.pyc
-__init__.py
diff --git a/product/ERP5Catalog/Document/__init__.py b/product/ERP5Catalog/Document/__init__.py
new file mode 100755
index 0000000000..e69de29bb2
diff --git a/product/ERP5Catalog/Interface/.cvsignore b/product/ERP5Catalog/Interface/.cvsignore
index 432ed787d1..d0743b7da6 100755
--- a/product/ERP5Catalog/Interface/.cvsignore
+++ b/product/ERP5Catalog/Interface/.cvsignore
@@ -1,3 +1,2 @@
 .AppleDouble
 *.pyc
-__init__.py
diff --git a/product/ERP5Catalog/Interface/__init__.py b/product/ERP5Catalog/Interface/__init__.py
new file mode 100755
index 0000000000..e69de29bb2
diff --git a/product/ERP5Catalog/PropertySheet/.cvsignore b/product/ERP5Catalog/PropertySheet/.cvsignore
index 432ed787d1..d0743b7da6 100755
--- a/product/ERP5Catalog/PropertySheet/.cvsignore
+++ b/product/ERP5Catalog/PropertySheet/.cvsignore
@@ -1,3 +1,2 @@
 .AppleDouble
 *.pyc
-__init__.py
diff --git a/product/ERP5Catalog/PropertySheet/__init__.py b/product/ERP5Catalog/PropertySheet/__init__.py
new file mode 100755
index 0000000000..e69de29bb2
diff --git a/product/ERP5Catalog/__init__.py b/product/ERP5Catalog/__init__.py
index 17f097c124..d90c573815 100755
--- a/product/ERP5Catalog/__init__.py
+++ b/product/ERP5Catalog/__init__.py
@@ -30,16 +30,11 @@
     and extended local roles management
 """
 
-# First import the minimal number of packages required by the code generation
-from Products.ERP5Type.InitGenerator import generateInitFiles
-import sys
-
-# Update the self generated code for Document, PropertySheet and Interface
-this_module = sys.modules[ __name__ ]
-document_classes = generateInitFiles(this_module, globals())
-
 # Update ERP5 Globals
 from Products.ERP5Type.Utils import initializeProduct, updateGlobals
+import sys, Permissions
+this_module = sys.modules[ __name__ ]
+document_classes = updateGlobals( this_module, globals(), permissions_module = Permissions)
 
 # Define object classes and tools
 import CatalogTool
diff --git a/product/ERP5Compatibility/__init__.py b/product/ERP5Compatibility/__init__.py
index ad9d4ae411..7a44a6d5a6 100755
--- a/product/ERP5Compatibility/__init__.py
+++ b/product/ERP5Compatibility/__init__.py
@@ -3,6 +3,7 @@ import Products.ERP5
 import Products.ERP5.XML
 import Products.ERP5.UI
 import Products.ERP5.Document
+import Products.ERP5.Document.SaleOpportunity
 import Products.ERP5Catalog
 import Products.ERP5Form
 import Products.ERP5SyncML
diff --git a/product/ERP5Form/Constraint/.cvsignore b/product/ERP5Form/Constraint/.cvsignore
index 432ed787d1..d0743b7da6 100755
--- a/product/ERP5Form/Constraint/.cvsignore
+++ b/product/ERP5Form/Constraint/.cvsignore
@@ -1,3 +1,2 @@
 .AppleDouble
 *.pyc
-__init__.py
diff --git a/product/ERP5Form/Constraint/__init__.py b/product/ERP5Form/Constraint/__init__.py
new file mode 100755
index 0000000000..e69de29bb2
diff --git a/product/ERP5Form/Document/.cvsignore b/product/ERP5Form/Document/.cvsignore
index 432ed787d1..d0743b7da6 100755
--- a/product/ERP5Form/Document/.cvsignore
+++ b/product/ERP5Form/Document/.cvsignore
@@ -1,3 +1,2 @@
 .AppleDouble
 *.pyc
-__init__.py
diff --git a/product/ERP5Form/Document/__init__.py b/product/ERP5Form/Document/__init__.py
new file mode 100755
index 0000000000..e69de29bb2
diff --git a/product/ERP5Form/Interface/.cvsignore b/product/ERP5Form/Interface/.cvsignore
index 432ed787d1..d0743b7da6 100755
--- a/product/ERP5Form/Interface/.cvsignore
+++ b/product/ERP5Form/Interface/.cvsignore
@@ -1,3 +1,2 @@
 .AppleDouble
 *.pyc
-__init__.py
diff --git a/product/ERP5Form/Interface/__init__.py b/product/ERP5Form/Interface/__init__.py
new file mode 100755
index 0000000000..e69de29bb2
diff --git a/product/ERP5Form/PropertySheet/.cvsignore b/product/ERP5Form/PropertySheet/.cvsignore
index 432ed787d1..d0743b7da6 100755
--- a/product/ERP5Form/PropertySheet/.cvsignore
+++ b/product/ERP5Form/PropertySheet/.cvsignore
@@ -1,3 +1,2 @@
 .AppleDouble
 *.pyc
-__init__.py
diff --git a/product/ERP5Form/PropertySheet/__init__.py b/product/ERP5Form/PropertySheet/__init__.py
new file mode 100755
index 0000000000..e69de29bb2
diff --git a/product/ERP5Form/__init__.py b/product/ERP5Form/__init__.py
index cb9a44e3a4..31e5571655 100755
--- a/product/ERP5Form/__init__.py
+++ b/product/ERP5Form/__init__.py
@@ -30,19 +30,11 @@
     with Zope
 """
 
-# First import the minimal number of packages required by the code generation
-from Products.ERP5Type.InitGenerator import generateInitFiles
-import sys
-
-# Update the self generated code for Document, PropertySheet and Interface
-this_module = sys.modules[ __name__ ]
-document_classes = generateInitFiles(this_module, globals())
-
 # Update ERP5 Globals
 from Products.ERP5Type.Utils import initializeProduct, updateGlobals
-import Permissions
-updateGlobals( this_module, globals(),
-                   permissions_module = Permissions)
+import sys, Permissions
+this_module = sys.modules[ __name__ ]
+document_classes = updateGlobals( this_module, globals(), permissions_module = Permissions)
 
 # Define object classes and tools
 import Form, FSForm, ListBox, MatrixBox, SelectionTool, ZGDChart, PDFTemplate
diff --git a/product/ERP5Shop/Constraint/.cvsignore b/product/ERP5Shop/Constraint/.cvsignore
index 654a6adb18..d0743b7da6 100755
--- a/product/ERP5Shop/Constraint/.cvsignore
+++ b/product/ERP5Shop/Constraint/.cvsignore
@@ -1,3 +1,2 @@
-__init__.py
 .AppleDouble
 *.pyc
diff --git a/product/ERP5Shop/Constraint/__init__.py b/product/ERP5Shop/Constraint/__init__.py
new file mode 100755
index 0000000000..e69de29bb2
diff --git a/product/ERP5Shop/Document/.cvsignore b/product/ERP5Shop/Document/.cvsignore
index 432ed787d1..d0743b7da6 100755
--- a/product/ERP5Shop/Document/.cvsignore
+++ b/product/ERP5Shop/Document/.cvsignore
@@ -1,3 +1,2 @@
 .AppleDouble
 *.pyc
-__init__.py
diff --git a/product/ERP5Shop/Document/__init__.py b/product/ERP5Shop/Document/__init__.py
new file mode 100755
index 0000000000..e69de29bb2
diff --git a/product/ERP5Shop/Interface/.cvsignore b/product/ERP5Shop/Interface/.cvsignore
index 432ed787d1..d0743b7da6 100755
--- a/product/ERP5Shop/Interface/.cvsignore
+++ b/product/ERP5Shop/Interface/.cvsignore
@@ -1,3 +1,2 @@
 .AppleDouble
 *.pyc
-__init__.py
diff --git a/product/ERP5Shop/Interface/__init__.py b/product/ERP5Shop/Interface/__init__.py
new file mode 100755
index 0000000000..e69de29bb2
diff --git a/product/ERP5Shop/PropertySheet/.cvsignore b/product/ERP5Shop/PropertySheet/.cvsignore
index 432ed787d1..d0743b7da6 100755
--- a/product/ERP5Shop/PropertySheet/.cvsignore
+++ b/product/ERP5Shop/PropertySheet/.cvsignore
@@ -1,3 +1,2 @@
 .AppleDouble
 *.pyc
-__init__.py
diff --git a/product/ERP5Shop/PropertySheet/__init__.py b/product/ERP5Shop/PropertySheet/__init__.py
new file mode 100755
index 0000000000..e69de29bb2
diff --git a/product/ERP5Shop/__init__.py b/product/ERP5Shop/__init__.py
index f3dc38a37a..79a430b73e 100755
--- a/product/ERP5Shop/__init__.py
+++ b/product/ERP5Shop/__init__.py
@@ -29,22 +29,11 @@
     ERP5Shop Free ERP + eCommerce
 """
 
-# First import the minimal number of packages required by the code generation
-from Products.ERP5Type.InitGenerator import generateInitFiles
-import sys
-
-# Update the self generated code for Document, PropertySheet and Interface
-this_module = sys.modules[ __name__ ]
-document_classes = generateInitFiles(this_module, globals())
-
 # Update ERP5 Globals
 from Products.ERP5Type.Utils import initializeProduct, updateGlobals
-import Interface, PropertySheet, Permissions, Constraint
-updateGlobals( this_module, globals(),
-                   property_sheet_module = PropertySheet,
-                   interface_module = Interface,
-                   permissions_module = Permissions,
-                   constraint_module = Constraint)
+import sys, Permissions
+this_module = sys.modules[ __name__ ]
+document_classes = updateGlobals( this_module, globals(), permissions_module = Permissions)
 
 # Define object classes and tools
 import ShopManager
diff --git a/product/ERP5SyncML/Constraint/.cvsignore b/product/ERP5SyncML/Constraint/.cvsignore
index 432ed787d1..d0743b7da6 100755
--- a/product/ERP5SyncML/Constraint/.cvsignore
+++ b/product/ERP5SyncML/Constraint/.cvsignore
@@ -1,3 +1,2 @@
 .AppleDouble
 *.pyc
-__init__.py
diff --git a/product/ERP5SyncML/Constraint/__init__.py b/product/ERP5SyncML/Constraint/__init__.py
new file mode 100755
index 0000000000..e69de29bb2
diff --git a/product/ERP5SyncML/Document/.cvsignore b/product/ERP5SyncML/Document/.cvsignore
index 432ed787d1..d0743b7da6 100755
--- a/product/ERP5SyncML/Document/.cvsignore
+++ b/product/ERP5SyncML/Document/.cvsignore
@@ -1,3 +1,2 @@
 .AppleDouble
 *.pyc
-__init__.py
diff --git a/product/ERP5SyncML/Document/__init__.py b/product/ERP5SyncML/Document/__init__.py
new file mode 100755
index 0000000000..e69de29bb2
diff --git a/product/ERP5SyncML/Interface/.cvsignore b/product/ERP5SyncML/Interface/.cvsignore
index 432ed787d1..d0743b7da6 100755
--- a/product/ERP5SyncML/Interface/.cvsignore
+++ b/product/ERP5SyncML/Interface/.cvsignore
@@ -1,3 +1,2 @@
 .AppleDouble
 *.pyc
-__init__.py
diff --git a/product/ERP5SyncML/Interface/__init__.py b/product/ERP5SyncML/Interface/__init__.py
new file mode 100755
index 0000000000..e69de29bb2
diff --git a/product/ERP5SyncML/PropertySheet/.cvsignore b/product/ERP5SyncML/PropertySheet/.cvsignore
index 432ed787d1..d0743b7da6 100755
--- a/product/ERP5SyncML/PropertySheet/.cvsignore
+++ b/product/ERP5SyncML/PropertySheet/.cvsignore
@@ -1,3 +1,2 @@
 .AppleDouble
 *.pyc
-__init__.py
diff --git a/product/ERP5SyncML/PropertySheet/__init__.py b/product/ERP5SyncML/PropertySheet/__init__.py
new file mode 100755
index 0000000000..e69de29bb2
diff --git a/product/ERP5SyncML/__init__.py b/product/ERP5SyncML/__init__.py
index b2ad23ce77..6dbea92416 100755
--- a/product/ERP5SyncML/__init__.py
+++ b/product/ERP5SyncML/__init__.py
@@ -30,24 +30,11 @@
     and extended local roles management
 """
 
-# First import the minimal number of packages required by the code generation
-from Products.ERP5Type.InitGenerator import generateInitFiles
-import sys
-
-# Update the self generated code for Document, PropertySheet and Interface
-this_module = sys.modules[ __name__ ]
-document_classes = generateInitFiles(this_module, globals())
-
 # Update ERP5 Globals
 from Products.ERP5Type.Utils import initializeProduct, updateGlobals
-import Interface, PropertySheet, Permissions, Constraint
-updateGlobals( this_module, globals(),
-               property_sheet_module = PropertySheet,
-               interface_module = Interface,
-               permissions_module = Permissions,
-               constraint_module = Constraint)
-
-
+import sys, Permissions
+this_module = sys.modules[ __name__ ]
+document_classes = updateGlobals( this_module, globals(), permissions_module = Permissions)
 
 # Define object classes and tools
 import SynchronizationTool
diff --git a/product/ERP5Type/Base.py b/product/ERP5Type/Base.py
index 553de30d51..a841abd40b 100755
--- a/product/ERP5Type/Base.py
+++ b/product/ERP5Type/Base.py
@@ -65,8 +65,17 @@ import random
 
 from zLOG import LOG
 
-class CallbaseError(AttributeError):
-    pass
+# Dynamic method acquisition system (code generation)
+aq_method_generated = {}
+
+def _initializeDefaultProperties(klass):
+  if not aq_method_generated.has_key(klass):
+    LOG('in aq_method_generated %s' % id, 0, str(klass.__name__))
+    from Utils import initializeDefaultProperties
+    initializeDefaultProperties([klass])
+    aq_method_generated[klass] = 1  
+    for super_klass in klass.__bases__:
+      _initializeDefaultProperties(super_klass)         
 
 class Base( CopyContainer, PortalContent, Base18, ActiveObject, ERP5PropertyManager ):
   """
@@ -114,6 +123,14 @@ class Base( CopyContainer, PortalContent, Base18, ActiveObject, ERP5PropertyMana
   # We want to use a default property view
   manage_propertiesForm = DTMLFile( 'dtml/properties', _dtmldir )
 
+  def _aq_dynamic(self, id):  
+    global aq_method_generated  
+    klass = self.__class__
+    if not aq_method_generated.has_key(klass):      
+      _initializeDefaultProperties(klass)
+      return getattr(self, id)
+    return None    
+    
   # Constructor
   def __init__(self, id, uid=None, rid=None, sid=None, **kw):
     self.id = id
diff --git a/product/ERP5Type/InitGenerator.py b/product/ERP5Type/InitGenerator.py
index ddb7efddab..a8880717a1 100755
--- a/product/ERP5Type/InitGenerator.py
+++ b/product/ERP5Type/InitGenerator.py
@@ -38,9 +38,8 @@ product_document_registry = []
 
 def InitializeDocument(document_class, document_path=None):
   global product_document_registry
-  InitializeClass(document_class)
   # Register class in ERP5Type.Document
-  product_document_registry.append(((document_class.__name__, document_path)))
+  product_document_registry.append(((document_class, document_path)))
   #LOG('InitializeDocument', 0, document_class.__name__)
 
 def initializeProductDocumentRegistry():
@@ -51,163 +50,4 @@ def initializeProductDocumentRegistry():
     #ZopeTestCase._print('Added product document to ERP5Type repository: %s (%s) \n' % (class_id, document_path))
     #LOG('Added product document to ERP5Type repository: %s (%s)' % (class_id, document_path), 0, '')
     #print 'Added product document to ERP5Type repository: %s (%s)' % (class_id, document_path)
-
-# Code Generation of __init__.py files
-def generateInitFiles(this_module, global_hook,
-                      generate_document=1, generate_property_sheet=1, generate_constraint=1, generate_interface=1):
-  # Determine product_path
-  product_path = package_home( global_hook )
-  # Add _dtmldir
-  this_module._dtmldir = os.path.join( product_path, 'dtml' )
-  # This regular expression is used to check is a file is a python file
-  python_file_expr = re.compile("py$")
-
-  # Create Document __init__.py file
-  document_path = product_path + '/Document'
-  document_module_name_list = []
-  document_module_lines = ["from Products.ERP5Type import Document as ERP5TypeDocumentRepository\n\n"]
-  try:
-    file_list = os.listdir(document_path)
-    for file_name in file_list:
-      if file_name != '__init__.py':
-        if python_file_expr.search(file_name,1):
-          module_name = file_name[0:-3]
-          document_module_name_list += [module_name]
-          document_module_lines += ["""\
-# Hide internal implementation
-from Products.ERP5Type.InitGenerator import InitializeDocument
-import %s as ERP5%s
-if not hasattr(ERP5TypeDocumentRepository, '_override_%s'): ERP5TypeDocumentRepository.%s = ERP5%s  # Never override a local Document class
-# Default constructor for %s
-# Can be overriden by adding a method add%s in class %s
-def add%s(folder, id, REQUEST=None, **kw):
-  o = ERP5TypeDocumentRepository.%s.%s(id)
-  folder._setObject(id, o)
-  o.uid = folder.portal_catalog.newUid()
-  if kw is not None: o.__of__(folder)._edit(force_update=1, **kw)
-  # contentCreate already calls reindex 3 times ...
-  # o.reindexObject()
-  if REQUEST is not None:
-      REQUEST['RESPONSE'].redirect( 'manage_main' )
-
-InitializeDocument(ERP5TypeDocumentRepository.%s.%s, document_path='%s')
-
-class Temp%s(ERP5TypeDocumentRepository.%s.%s):
-  isIndexable = 0
-
-  def reindexObject(self, *args, **kw):
-    pass
-
-  def recursiveReindexObject(self, *args, **kw):
-    pass
-
-  def activate(self):
-    return self
-
-  def setUid(self, value):
-    self.uid = value # Make sure no casting happens when we use Temp classes to create new objects
-
-from Products.PythonScripts.Utility import allow_class
-allow_class(Temp%s)
-
-def newTemp%s(folder, id, REQUEST=None, **kw):
-  o = Temp%s(id)
-  o = o.__of__(folder)
-  if kw is not None: o._edit(force_update=1, **kw)
-  return o
-
-ERP5TypeDocumentRepository.newTemp%s = newTemp%s
-from AccessControl import ModuleSecurityInfo
-ModuleSecurityInfo('Products.ERP5Type.Document').declarePublic('newTemp%s',)
-
-""" % (module_name, module_name,
-       module_name, module_name, module_name,
-       module_name,
-       module_name, module_name,
-       module_name,
-       module_name, module_name,
-       module_name, module_name, document_path,
-       module_name, module_name, module_name,
-       module_name,
-       module_name,
-       module_name,
-       module_name, module_name,
-       module_name,)]
-
-    if generate_document:
-      try:
-        document_init_file = open(document_path + '/__init__.py', 'w')
-        document_init_file.write(string.join(document_module_lines, '\n'))
-        document_init_file.close()
-      except:
-        LOG('ERP5Type:',0,'Could not write Document __init__.py files for %s' % product_path)
-  except:
-      LOG('ERP5Type:',0,'No Document directory in %s' % product_path)
-
-  # Create Property __init__.py file
-  property_path = product_path + '/PropertySheet'
-  property_module_name_list = []
-  property_module_lines = []
-  try:
-    file_list = os.listdir(property_path)
-    for file_name in file_list:
-      if file_name != '__init__.py':
-        if python_file_expr.search(file_name,1):
-          module_name = file_name[0:-3]
-          property_module_name_list += [module_name]
-          property_module_lines += ['from %s import %s' % (module_name, module_name)]
-    if generate_property_sheet:
-      try:
-        property_init_file = open(property_path + '/__init__.py', 'w')
-        property_init_file.write(string.join(property_module_lines, '\n'))
-        property_init_file.close()
-      except:
-        LOG('ERP5Type:',0,'Could not write PropertySheet __init__.py files for %s' % product_path)
-  except:
-      LOG('ERP5Type:',0,'No PropertySheet directory in %s' % product_path)
-
-  # Create Interface __init__.py file
-  interface_path = product_path + '/Interface'
-  interface_module_name_list = []
-  interface_module_lines = []
-  try:
-    file_list = os.listdir(interface_path)
-    for file_name in file_list:
-      if file_name != '__init__.py':
-        if python_file_expr.search(file_name,1):
-          module_name = file_name[0:-3]
-          interface_module_name_list += [module_name]
-          interface_module_lines += ['from %s import %s' % (module_name, module_name)]
-    if generate_interface:
-      try:
-        interface_init_file = open(interface_path + '/__init__.py', 'w')
-        interface_init_file.write(string.join(interface_module_lines, '\n'))
-        interface_init_file.close()
-      except:
-        LOG('ERP5Type:',0,'Could not write Interface __init__.py files for %s' % product_path)
-  except:
-      LOG('ERP5Type:',0,'No Interface directory in %s' % product_path)
-
-  # Create Constraint __init__.py file
-  constraint_path = product_path + '/Constraint'
-  constraint_module_name_list = []
-  constraint_module_lines = []
-  try:
-    file_list = os.listdir(constraint_path)
-    for file_name in file_list:
-      if file_name != '__init__.py':
-        if python_file_expr.search(file_name,1):
-          module_name = file_name[0:-3]
-          constraint_module_name_list += [module_name]
-          constraint_module_lines += ['from %s import %s' % (module_name, module_name)]
-    if generate_constraint:
-      try:
-        constraint_init_file = open(constraint_path + '/__init__.py', 'w')
-        constraint_init_file.write(string.join(constraint_module_lines, '\n'))
-        constraint_init_file.close()
-      except:
-        LOG('ERP5Type:',0,'Could not write Constraint __init__.py files for %s' % product_path)
-  except:
-      LOG('ERP5Type:',0,'No Constraint directory in %s' % product_path)
-
-  return document_module_name_list
+    
diff --git a/product/ERP5Type/PropertySheet/__init__.py b/product/ERP5Type/PropertySheet/__init__.py
index 297a90321f..4a10a34b95 100755
--- a/product/ERP5Type/PropertySheet/__init__.py
+++ b/product/ERP5Type/PropertySheet/__init__.py
@@ -1,5 +1,5 @@
 from Base import Base
-from XMLObject import XMLObject
-from SimpleItem import SimpleItem
 from DublinCore import DublinCore
-from Folder import Folder
\ No newline at end of file
+from Folder import Folder
+from SimpleItem import SimpleItem
+from XMLObject import XMLObject
\ No newline at end of file
diff --git a/product/ERP5Type/Utils.py b/product/ERP5Type/Utils.py
index 84110df925..887718d53e 100755
--- a/product/ERP5Type/Utils.py
+++ b/product/ERP5Type/Utils.py
@@ -40,12 +40,6 @@ from Products.ERP5Type import Constraint
 from Products.ERP5Type import Interface
 from Products.ERP5Type import PropertySheet
 
-# This is really uggly... and we want to improve it
-import Products.ERP5Type.Constraint.CategoryMembershipArity
-import Products.ERP5Type.Constraint.AttributeEquality
-import Products.ERP5Type.Constraint.PropertyTypeValidity
-import Products.ERP5Type.Constraint.CategoryRelatedMembershipArity
-
 from zLOG import LOG
 
 #####################################################
@@ -149,48 +143,68 @@ def getPath(o):
 # Globals initialization
 #####################################################
 
+from InitGenerator import InitializeDocument
+
+# List Regexp
+python_file_expr = re.compile("py$")
+
+def getModuleIdList(product_path, module_id):
+  global python_file_expr
+  path = os.path.join(product_path, module_id)  
+  module_name_list = []
+  module_lines = []
+  try:
+    file_list = os.listdir(path)
+    for file_name in file_list:
+      if file_name != '__init__.py':
+        if python_file_expr.search(file_name,1):
+          module_name = file_name[0:-3]
+          module_name_list += [module_name]
+  except:
+      LOG('ERP5Type:',0,'No PropertySheet directory in %s' % product_path)
+  return path, module_name_list
+
 # EPR5Type global modules update
-def updateGlobals( this_module, global_hook,
-                   property_sheet_module = None,
-                   interface_module = None,
-                   permissions_module = None,
-                   constraint_module = None):
+def updateGlobals( this_module, global_hook, permissions_module = None, is_erp5_type=0):
   """
     This function does all the initialization steps required
     for a Zope / CMF Product
   """
-  product_name = this_module.__name__.split('.')[-1]
-
-  # Update PropertySheet
-  if property_sheet_module is not None:
-    for key in dir(property_sheet_module):
-      # Do not consider private keys
-      if key[0:2] != '__':
-        setattr(PropertySheet, key, getattr(property_sheet_module, key))
-
-  # Update Interface
-  if interface_module is not None:
-    for key in dir(interface_module):
-      # Do not consider private keys
-      if key[0:2] != '__':
-        setattr(Interface, key, getattr(interface_module, key))
-
-  # Update Permissions
-  if permissions_module is not None:
-    for key in dir(permissions_module):
-      # Do not consider private keys
-      if key[0:2] != '__':
-        setattr(Permissions, key, getattr(permissions_module, key))
-
-  # Update Constraint
-  if constraint_module is not None:
-    for key in dir(constraint_module):
-      # Do not consider private keys
-      if key[0:2] != '__':
-        setattr(Constraint, key, getattr(constraint_module, key))
-
-
-
+  product_path = package_home( global_hook )
+  
+  if not is_erp5_type:
+    # Add _dtmldir
+    this_module._dtmldir = os.path.join( product_path, 'dtml' )
+  
+    # Update PropertySheet Registry
+    for module_id in ('PropertySheet', 'Interface', 'Constraint', ):
+      path, module_id_list = getModuleIdList(product_path, module_id)
+      print path
+      print module_id_list
+      if module_id == 'PropertySheet':
+        import_method = importLocalPropertySheet
+      elif module_id == 'Interface':
+        import_method = importLocalInterface
+      elif module_id == 'Constraint':
+        import_method = importLocalConstraint
+      else:
+        import_method = None
+      for module_id in module_id_list:
+        import_method(module_id, path=path)
+  
+    # Update Permissions
+    if permissions_module is not None:
+      for key in dir(permissions_module):
+        # Do not consider private keys
+        if key[0:2] != '__':
+          setattr(Permissions, key, getattr(permissions_module, key))
+
+  # Return document_class list
+  path, module_id_list = getModuleIdList(product_path, 'Document')
+  for document in module_id_list:
+    InitializeDocument(document, document_path=path)
+  return module_id_list
+        
 #####################################################
 # Modules Import
 #####################################################
@@ -255,17 +269,36 @@ def writeLocalPropertySheet(class_id, text):
   f = open(path, 'w')
   f.write(text)
 
-def importLocalPropertySheet(class_id):
+def importLocalPropertySheet(class_id, path = None):
   import Products.ERP5Type.PropertySheet
-  import Permissions
-  import Products
-  instance_home = getConfiguration().instancehome
-  path = os.path.join(instance_home, "PropertySheet")
+  if path is None:
+    instance_home = getConfiguration().instancehome
+    path = os.path.join(instance_home, "PropertySheet")
   path = os.path.join(path, "%s.py" % class_id)
   f = open(path)
   module = imp.load_source(class_id, path, f)
   setattr(Products.ERP5Type.PropertySheet, class_id, getattr(module, class_id))
 
+def importLocalInterface(class_id, path = None):
+  import Products.ERP5Type.Interface
+  if path is None:
+    instance_home = getConfiguration().instancehome
+    path = os.path.join(instance_home, "Interface")
+  path = os.path.join(path, "%s.py" % class_id)
+  f = open(path)
+  module = imp.load_source(class_id, path, f)
+  setattr(Products.ERP5Type.Interface, class_id, getattr(module, class_id))
+
+def importLocalConstraint(class_id, path = None):
+  import Products.ERP5Type.Interface
+  if path is None:
+    instance_home = getConfiguration().instancehome
+    path = os.path.join(instance_home, "Constraint")
+  path = os.path.join(path, "%s.py" % class_id)
+  f = open(path)
+  module = imp.load_source(class_id, path, f)
+  setattr(Products.ERP5Type.Constraint, class_id, getattr(module, class_id))
+
 def getLocalExtensionList():
   if not getConfiguration: return []
   instance_home = getConfiguration().instancehome
@@ -386,13 +419,12 @@ def importLocalDocument(class_id, document_path = None):
   document_constructor = DocumentConstructor(document_class)
   document_constructor_name = "add%s" % class_id
   document_constructor.__name__ = document_constructor_name
-  default_permission = ('Manager',)
-  document_constructor.__roles__=None # XXX This is a security breach which needs to be fixed
+  default_permission = ('Manager',)  
   setattr(Products.ERP5Type.Document, class_id, document_module)
   setattr(Products.ERP5Type.Document, document_constructor_name, document_constructor)
   setDefaultClassProperties(document_class)
   pr=PermissionRole(document_class.add_permission, default_permission)
-  initializeDefaultProperties([document_class])
+  document_constructor.__roles__ = pr # There used to be security breach which was fixed (None replaced by pr)
   InitializeClass(document_class)
   # Update Meta Types
   new_meta_types = []
@@ -454,7 +486,7 @@ def initializeLocalDocumentRegistry():
           LOG('Added local document to ERP5Type repository: %s (%s)' % (module_name, document_path),0,'')
           print 'Added local document to ERP5Type repository: %s (%s)' % (module_name, document_path)
         except:
-          LOG('Failed to add local document to ERP5Type repository: %s (%s)' % (module_name, document_path) % (module_name, document_path),0,'')
+          LOG('Failed to add local document to ERP5Type repository: %s (%s)' % (module_name, document_path),0,'')
           print 'Failed to add local document to ERP5Type repository: %s (%s)' % (module_name, document_path)
 
 #####################################################
@@ -479,7 +511,8 @@ def initializeProduct( context, this_module, global_hook,
   # Define content classes from document_classes
   #LOG('Begin initializeProduct %s %s' % (document_module, document_classes),0,'')
   extra_content_classes = []
-  if document_module is not None:
+  #if document_module is not None:
+  if 0:
     for module_name in document_classes:
       #LOG('Inspecting %s %s' % (document_module, module_name),0,'')
       candidate = getattr(document_module, module_name)
@@ -491,10 +524,11 @@ def initializeProduct( context, this_module, global_hook,
 
   # Initialize Default Properties and Constructors for RAD classes
   if INITIALIZE_PRODUCT_RAD:
-    initializeDefaultProperties(content_classes)
-    initializeDefaultProperties(extra_content_classes)
+    #initializeDefaultProperties(content_classes)
+    #initializeDefaultProperties(extra_content_classes)
     initializeDefaultProperties(object_classes)
     #initializeDefaultConstructors(content_classes) Does not work yet
+    
 
   # Define content constructors for Document content classes (RAD)
   extra_content_constructors = []
@@ -667,7 +701,7 @@ def setDefaultProperties(klass):
       createCategoryAccessors(klass, cat)
       createValueAccessors(klass, cat)
     # Create the constraint method list - always check type
-    klass.constraints = [Products.ERP5Type.Constraint.PropertyTypeValidity(id='type_check')]
+    klass.constraints = [Constraint.PropertyTypeValidity(id='type_check')]
     for const in constraint_list:
       createConstraintList(klass, constraint_definition=const)
     # ERP5 _properties and Zope _properties are somehow different
diff --git a/product/ERP5Type/__init__.py b/product/ERP5Type/__init__.py
index aff162dc7a..809e4b0afb 100755
--- a/product/ERP5Type/__init__.py
+++ b/product/ERP5Type/__init__.py
@@ -30,18 +30,14 @@
     All ERP5 classes derive from ERP5Type
 """
 
-# First import the minimal number of packages required by the code generation
-from Products.ERP5Type.InitGenerator import generateInitFiles
-import sys
-
-# Update the self generated code for Document, PropertySheet and Interface
+# Update ERP5 Globals
+import sys, Permissions, os
+from Globals import package_home
 this_module = sys.modules[ __name__ ]
-document_classes = generateInitFiles(this_module, globals(), generate_document=0)
-
-# Import rest of the code and finish installation
-from Products.ERP5Type.Utils import initializeProduct, initializeLocalDocumentRegistry
-import Interface, PropertySheet, ZopePatch, StateChangeInfoPatch, \
-       CMFCorePatch
+product_path = package_home( globals() )
+this_module._dtmldir = os.path.join( product_path, 'dtml' )
+from Products.ERP5Type.Utils import initializeProduct, updateGlobals
+document_classes = updateGlobals( this_module, globals(), permissions_module = Permissions, is_erp5_type = 1)
 
 def initialize( context ):
   # Import Product Components
@@ -60,10 +56,18 @@ def initialize( context ):
                          object_classes = object_classes,
                          portal_tools = portal_tools,
                          content_constructors = content_constructors,
-                         content_classes = content_classes)
-  # We should register local classes at some point
+                         content_classes = content_classes)  
+#   # We should register interface classes at some point
+#   from Products.ERP5Type.InitGenerator import initializeProductInterfaceRegistry
+#   initializeProductInterfaceRegistry()
+#   # We should register property sheet classes at some point
+#   from Products.ERP5Type.InitGenerator import initializeProductPropertySheetRegistry
+#   initializeProductPropertySheetRegistry()    
+  # We should register product classes at some point
   from Products.ERP5Type.InitGenerator import initializeProductDocumentRegistry
   initializeProductDocumentRegistry()
+  # We should register local classes at some point
+  from Products.ERP5Type.Utils import initializeLocalDocumentRegistry
   initializeLocalDocumentRegistry()
 
 from AccessControl.SecurityInfo import allow_module
diff --git a/product/Nexedi/Constraint/.cvsignore b/product/Nexedi/Constraint/.cvsignore
index 432ed787d1..d0743b7da6 100755
--- a/product/Nexedi/Constraint/.cvsignore
+++ b/product/Nexedi/Constraint/.cvsignore
@@ -1,3 +1,2 @@
 .AppleDouble
 *.pyc
-__init__.py
diff --git a/product/Nexedi/Constraint/__init__.py b/product/Nexedi/Constraint/__init__.py
new file mode 100755
index 0000000000..e69de29bb2
diff --git a/product/Nexedi/Document/.cvsignore b/product/Nexedi/Document/.cvsignore
index 432ed787d1..d0743b7da6 100755
--- a/product/Nexedi/Document/.cvsignore
+++ b/product/Nexedi/Document/.cvsignore
@@ -1,3 +1,2 @@
 .AppleDouble
 *.pyc
-__init__.py
diff --git a/product/Nexedi/Document/__init__.py b/product/Nexedi/Document/__init__.py
new file mode 100755
index 0000000000..e69de29bb2
diff --git a/product/Nexedi/Interface/.cvsignore b/product/Nexedi/Interface/.cvsignore
index 432ed787d1..d0743b7da6 100755
--- a/product/Nexedi/Interface/.cvsignore
+++ b/product/Nexedi/Interface/.cvsignore
@@ -1,3 +1,2 @@
 .AppleDouble
 *.pyc
-__init__.py
diff --git a/product/Nexedi/Interface/__init__.py b/product/Nexedi/Interface/__init__.py
new file mode 100755
index 0000000000..e69de29bb2
diff --git a/product/Nexedi/PropertySheet/.cvsignore b/product/Nexedi/PropertySheet/.cvsignore
index 432ed787d1..d0743b7da6 100755
--- a/product/Nexedi/PropertySheet/.cvsignore
+++ b/product/Nexedi/PropertySheet/.cvsignore
@@ -1,3 +1,2 @@
 .AppleDouble
 *.pyc
-__init__.py
diff --git a/product/Nexedi/PropertySheet/__init__.py b/product/Nexedi/PropertySheet/__init__.py
new file mode 100755
index 0000000000..e69de29bb2
diff --git a/product/Nexedi/__init__.py b/product/Nexedi/__init__.py
index c63f1b9013..f6293e198b 100755
--- a/product/Nexedi/__init__.py
+++ b/product/Nexedi/__init__.py
@@ -29,22 +29,11 @@
     ERP5 Free Software ERP
 """
 
-# First import the minimal number of packages required by the code generation
-from Products.ERP5Type.InitGenerator import generateInitFiles
-import sys
-
-# Update the self generated code for Document, PropertySheet and Interface
-this_module = sys.modules[ __name__ ]
-document_classes = generateInitFiles(this_module, globals())
-
 # Update ERP5 Globals
 from Products.ERP5Type.Utils import initializeProduct, updateGlobals
-import Interface, PropertySheet, Permissions, Constraint
-updateGlobals( this_module, globals(),
-                   property_sheet_module = PropertySheet,
-                   interface_module = Interface,
-                   permissions_module = Permissions,
-                   constraint_module = Constraint)
+import sys, Permissions
+this_module = sys.modules[ __name__ ]
+document_classes = updateGlobals( this_module, globals(), permissions_module = Permissions)
 
 # Define object classes and tools
 object_classes = ()
-- 
2.30.9