From e48a89dc21ac044283b02d369450c48d0eea7abe Mon Sep 17 00:00:00 2001 From: Arnaud Fontaine <arnaud.fontaine@nexedi.com> Date: Wed, 29 Feb 2012 15:37:11 +0900 Subject: [PATCH] Do not reset Components on ComponentTool _setObject and _delObject. The only purpose of having Interaction Workflow defined on ComponentTool _setObject and _delObject was for BusinessTemplate installation and uninstallation, however the reset was also triggered when a new draft Component was being added. Instead, perform the reset in BusinessTemplate DocumentTemplateItem. --- product/ERP5/Document/BusinessTemplate.py | 24 ++++- .../workflow_chain_type.xml | 4 - .../interactions/ComponentTool_reset.xml | 97 ------------------- .../ERP5/bootstrap/erp5_core/bt/change_log | 3 + product/ERP5/bootstrap/erp5_core/bt/revision | 2 +- .../template_portal_type_workflow_chain_list | 1 - 6 files changed, 23 insertions(+), 108 deletions(-) delete mode 100644 product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/dynamic_class_generation_interaction_workflow/interactions/ComponentTool_reset.xml diff --git a/product/ERP5/Document/BusinessTemplate.py b/product/ERP5/Document/BusinessTemplate.py index a0c7149a26..5116240edc 100644 --- a/product/ERP5/Document/BusinessTemplate.py +++ b/product/ERP5/Document/BusinessTemplate.py @@ -3561,6 +3561,12 @@ class FilesystemToZodbTemplateItem(FilesystemDocumentTemplateItem, return FilesystemDocumentTemplateItem._importFile(self, file_name, *args, **kw) + def afterUninstall(self, already_migrated=False): + """ + Hook called after uninstall + """ + pass + def uninstall(self, *args, **kw): # Only for uninstall, the path of objects can be given as a # parameter, otherwise it fallbacks on '_archive' @@ -3570,10 +3576,13 @@ class FilesystemToZodbTemplateItem(FilesystemDocumentTemplateItem, else: object_keys = self._archive.keys() - if self._is_already_migrated(object_keys): - return ObjectTemplateItem.uninstall(self, *args, **kw) + already_migrated = self._is_already_migrated(object_keys) + if already_migrated: + ObjectTemplateItem.uninstall(self, *args, **kw) else: - return FilesystemDocumentTemplateItem.uninstall(self, *args, **kw) + FilesystemDocumentTemplateItem.uninstall(self, *args, **kw) + + self.afterUninstall(already_migrated) def remove(self, context, **kw): """ @@ -3874,9 +3883,14 @@ class DocumentTemplateItem(FilesystemToZodbTemplateItem): self._objects or self._archive)) if self._is_already_migrated(object_list): - return ObjectTemplateItem.install(self, context, **kw) + ObjectTemplateItem.install(self, context, **kw) + self.portal_components.reset(force=True, reset_portal_type=True) else: - return FilesystemDocumentTemplateItem.install(self, context, **kw) + FilesystemDocumentTemplateItem.install(self, context, **kw) + + def afterUninstall(self, already_migrated=False): + if already_migrated: + self.portal_components.reset(force=True, reset_portal_type=True) from Products.ERP5Type.Core.ExtensionComponent import ExtensionComponent as \ ExtensionComponentDocument diff --git a/product/ERP5/bootstrap/erp5_core/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml b/product/ERP5/bootstrap/erp5_core/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml index f9db7f1c79..97786dfc12 100644 --- a/product/ERP5/bootstrap/erp5_core/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml +++ b/product/ERP5/bootstrap/erp5_core/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml @@ -71,10 +71,6 @@ <type>Category Tool</type> <workflow>dynamic_class_generation_interaction_workflow</workflow> </chain> - <chain> - <type>Component Tool</type> - <workflow>dynamic_class_generation_interaction_workflow</workflow> - </chain> <chain> <type>Content Existence Constraint</type> <workflow>dynamic_class_generation_interaction_workflow</workflow> diff --git a/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/dynamic_class_generation_interaction_workflow/interactions/ComponentTool_reset.xml b/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/dynamic_class_generation_interaction_workflow/interactions/ComponentTool_reset.xml deleted file mode 100644 index 06e3901c10..0000000000 --- a/product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/dynamic_class_generation_interaction_workflow/interactions/ComponentTool_reset.xml +++ /dev/null @@ -1,97 +0,0 @@ -<?xml version="1.0"?> -<ZopeData> - <record id="1" aka="AAAAAAAAAAE="> - <pickle> - <global name="InteractionDefinition" module="Products.ERP5.Interaction"/> - </pickle> - <pickle> - <dictionary> - <item> - <key> <string>actbox_category</string> </key> - <value> <string>workflow</string> </value> - </item> - <item> - <key> <string>actbox_name</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>actbox_url</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>activate_script_name</string> </key> - <value> - <tuple/> - </value> - </item> - <item> - <key> <string>after_script_name</string> </key> - <value> - <tuple/> - </value> - </item> - <item> - <key> <string>before_commit_script_name</string> </key> - <value> - <list> - <string>ComponentTool_reset</string> - </list> - </value> - </item> - <item> - <key> <string>description</string> </key> - <value> <string>When a Component is deleted or added in Component Tool, reset all Components</string> </value> - </item> - <item> - <key> <string>guard</string> </key> - <value> - <none/> - </value> - </item> - <item> - <key> <string>id</string> </key> - <value> <string>ComponentTool_reset</string> </value> - </item> - <item> - <key> <string>method_id</string> </key> - <value> - <list> - <string>_delObject</string> - <string>_setObject</string> - </list> - </value> - </item> - <item> - <key> <string>once_per_transaction</string> </key> - <value> <int>1</int> </value> - </item> - <item> - <key> <string>portal_type_filter</string> </key> - <value> - <list> - <string>Component Tool</string> - </list> - </value> - </item> - <item> - <key> <string>script_name</string> </key> - <value> - <tuple/> - </value> - </item> - <item> - <key> <string>temporary_document_disallowed</string> </key> - <value> <int>0</int> </value> - </item> - <item> - <key> <string>title</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>trigger_type</string> </key> - <value> <int>2</int> </value> - </item> - </dictionary> - </pickle> - </record> -</ZopeData> diff --git a/product/ERP5/bootstrap/erp5_core/bt/change_log b/product/ERP5/bootstrap/erp5_core/bt/change_log index 4845bfd946..03dc575baf 100644 --- a/product/ERP5/bootstrap/erp5_core/bt/change_log +++ b/product/ERP5/bootstrap/erp5_core/bt/change_log @@ -1,3 +1,6 @@ +2012-02-29 arnaud.fontaine +* Do not reset Components on ComponentTool _setObject and _delObject, instead reset in BusinessTemplate to avoid reset being triggered when a new Component is created. + 2012-02-28 arnaud.fontaine * Rename version_priority ERP5Site property to version_priority_list. diff --git a/product/ERP5/bootstrap/erp5_core/bt/revision b/product/ERP5/bootstrap/erp5_core/bt/revision index 6200434381..c7401e76ab 100644 --- a/product/ERP5/bootstrap/erp5_core/bt/revision +++ b/product/ERP5/bootstrap/erp5_core/bt/revision @@ -1 +1 @@ -41015 \ No newline at end of file +41016 \ No newline at end of file diff --git a/product/ERP5/bootstrap/erp5_core/bt/template_portal_type_workflow_chain_list b/product/ERP5/bootstrap/erp5_core/bt/template_portal_type_workflow_chain_list index bd4afe30bf..60b2320da4 100644 --- a/product/ERP5/bootstrap/erp5_core/bt/template_portal_type_workflow_chain_list +++ b/product/ERP5/bootstrap/erp5_core/bt/template_portal_type_workflow_chain_list @@ -19,7 +19,6 @@ Category Related Membership Arity Constraint | dynamic_class_generation_interact Category Related Membership State Constraint | dynamic_class_generation_interaction_workflow Category Tool | dynamic_class_generation_interaction_workflow Category | edit_workflow -Component Tool | dynamic_class_generation_interaction_workflow Content Existence Constraint | dynamic_class_generation_interaction_workflow Distributed Ram Cache | distributed_ram_cache_interaction_workflow Document Component | component_validation_workflow -- 2.30.9