[Erp5-report] r36699 kazuhiko - /erp5/trunk/products/ERP5/Document/BusinessTemplate.py

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Jun 29 16:37:23 CEST 2010


Author: kazuhiko
Date: Tue Jun 29 16:37:23 2010
New Revision: 36699

URL: http://svn.erp5.org?rev=36699&view=rev
Log:
Register type provider by installing ITypeProvider tool instead of installing portal types whose parent is not yet registered as type provider. This change make it possible to put only the tool in a business template without putting its inside portal types.

Modified:
    erp5/trunk/products/ERP5/Document/BusinessTemplate.py

Modified: erp5/trunk/products/ERP5/Document/BusinessTemplate.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/BusinessTemplate.py?rev=36699&r1=36698&r2=36699&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/BusinessTemplate.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/BusinessTemplate.py [utf8] Tue Jun 29 16:37:23 2010
@@ -1343,6 +1343,19 @@ class ToolTemplateItem(PathTemplateItem)
     return PathTemplateItem._backupObject(self, action, None, container_path,
                                           object_id, **kw)
 
+  def onNewObject(self, obj):
+    """ When we install a tool that is a type provider not
+    registered on types tool, register the type provider.
+    """
+    portal = obj.getPortalObject()
+    types_tool = portal.portal_types
+    type_container_id = obj.getId()
+    if interfaces.ITypeProvider.isImplementedBy(obj) and \
+        type_container_id not in types_tool.type_provider_list:
+      types_tool.type_provider_list = tuple(types_tool.type_provider_list) + \
+                                      (type_container_id,)
+    return PathTemplateItem.onNewObject(self, obj)
+
 class PreferenceTemplateItem(PathTemplateItem):
   """
   This class is used to store preference objects
@@ -1785,18 +1798,6 @@ class PortalTypeTemplateItem(ObjectTempl
           delattr(obj, attr)
       self._objects[relative_url] = obj
       obj.wl_clearLocks()
-  
-  def onNewObject(self, obj):
-    """ When we install a type which is contained in a type provider not
-    registered on types tool, register the type provider.
-    """
-    portal = obj.getPortalObject()
-    types_tool = portal.portal_types
-    type_container_id = obj.getParentId()
-    if type_container_id != 'portal_types' and \
-        type_container_id not in types_tool.type_provider_list:
-      types_tool.type_provider_list = tuple(types_tool.type_provider_list) + (
-          type_container_id,)
 
   # XXX : this method is kept temporarily, but can be removed once all bt5 are
   # re-exported with separated workflow-chain information




More information about the Erp5-report mailing list