[Erp5-report] r29543 - in /erp5/trunk/products/ERP5Type: InitGenerator.py Utils.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Fri Oct 9 17:09:41 CEST 2009
Author: jp
Date: Fri Oct 9 17:09:40 2009
New Revision: 29543
URL: http://svn.erp5.org?rev=29543&view=rev
Log:
Refactored version of Interactor with compoenent sysytem
Modified:
erp5/trunk/products/ERP5Type/InitGenerator.py
erp5/trunk/products/ERP5Type/Utils.py
Modified: erp5/trunk/products/ERP5Type/InitGenerator.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/InitGenerator.py?rev=29543&r1=29542&r2=29543&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/InitGenerator.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/InitGenerator.py [utf8] Fri Oct 9 17:09:40 2009
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved.
@@ -35,6 +36,10 @@
global product_document_registry
product_document_registry = []
+global product_interactor_registry
+product_interactor_registry = []
+global interactor_class_id_registry
+interactor_class_id_registry = {}
def getProductDocumentPathList():
result = product_document_registry
@@ -45,7 +50,16 @@
global product_document_registry
# Register class in ERP5Type.Document
product_document_registry.append(((document_class, document_path)))
- #LOG('InitializeDocument', 0, document_class.__name__)
+
+def getProductInteractorPathList():
+ result = product_interactor_registry
+ result.sort()
+ return result
+
+def InitializeInteractor(interactor_class, interactor_path=None):
+ global product_interactor_registry
+ # Register class in ERP5Type.Interactor
+ product_interactor_registry.append(((interactor_class, interactor_path)))
def initializeProductDocumentRegistry():
from Utils import importLocalDocument
@@ -56,3 +70,17 @@
#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)
+def initializeProductInteractorRegistry():
+ from Utils import importLocalInteractor
+ for (class_id, interactor_path) in product_interactor_registry:
+ if class_id != 'Interactor': # Base class can not be global and placeless
+ importLocalInteractor(class_id, path=interactor_path)
+
+def registerInteractorClass(class_id, klass):
+ global interactor_class_id_registry
+ interactor_class_id_registry[class_id] = klass
+
+def installInteractorClassRegistry():
+ global interactor_class_id_registry
+ for class_id, klass in interactor_class_id_registry.items():
+ klass().install()
Modified: erp5/trunk/products/ERP5Type/Utils.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Utils.py?rev=29543&r1=29542&r2=29543&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Utils.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Utils.py [utf8] Fri Oct 9 17:09:40 2009
@@ -319,7 +319,7 @@
# Globals initialization
#####################################################
-from InitGenerator import InitializeDocument
+from InitGenerator import InitializeDocument, InitializeInteractor, registerInteractorClass
# List Regexp
python_file_expr = re.compile("py$")
@@ -355,7 +355,7 @@
this_module._dtmldir = os.path.join( product_path, 'dtml' )
# Update PropertySheet Registry
- for module_id in ('PropertySheet', 'interfaces', 'Constraint', ):
+ for module_id in ('PropertySheet', 'interfaces', 'Constraint'):
path, module_id_list = getModuleIdList(product_path, module_id)
if module_id == 'PropertySheet':
import_method = importLocalPropertySheet
@@ -383,6 +383,12 @@
path, module_id_list = getModuleIdList(product_path, 'Document')
for document in module_id_list:
InitializeDocument(document, document_path=path)
+
+ # Return interactor_class list
+ path, interactor_id_list = getModuleIdList(product_path, 'Interactor')
+ for interactor in interactor_id_list:
+ InitializeInteractor(interactor, interactor_path=path)
+
return module_id_list + core_module_id_list
#####################################################
@@ -564,6 +570,20 @@
try:
module = imp.load_source(class_id, path, f)
setattr(Products.ERP5Type.Constraint, class_id, getattr(module, class_id))
+ finally:
+ f.close()
+
+def importLocalInteractor(class_id, path=None):
+ import Products.ERP5Type.Interactor
+ if path is None:
+ instance_home = getConfiguration().instancehome
+ path = os.path.join(instance_home, "Interactor")
+ path = os.path.join(path, "%s.py" % class_id)
+ f = open(path)
+ try:
+ module = imp.load_source(class_id, path, f)
+ setattr(Products.ERP5Type.Interactor, class_id, getattr(module, class_id))
+ registerInteractorClass(class_id, getattr(Products.ERP5Type.Interactor, class_id))
finally:
f.close()
@@ -801,6 +821,7 @@
import Products.ERP5Type.Document
import Permissions
import Products
+
if document_path is None:
instance_home = getConfiguration().instancehome
path = os.path.join(instance_home, "Document")
@@ -934,6 +955,10 @@
def initializeLocalConstraintRegistry():
initializeLocalRegistry("Constraint", importLocalConstraint)
+def initializeLocalInteractorRegistry():
+ initializeLocalRegistry("Interactor", importLocalInteractor)
+
+
#####################################################
# Product initialization
#####################################################
@@ -942,7 +967,7 @@
this_module,
global_hook,
document_module=None,
- document_classes=None,
+ document_classes=None, # XXX - Never used - must be likely removed
object_classes=None,
portal_tools=None,
content_constructors=None,
More information about the Erp5-report
mailing list