Commit 187d49ae authored by Jérome Perrin's avatar Jérome Perrin

Use an interaction workflow to clear preference cache

parent a24b251b
...@@ -109,7 +109,7 @@ ...@@ -109,7 +109,7 @@
</chain> </chain>
<chain> <chain>
<type>Preference</type> <type>Preference</type>
<workflow>edit_workflow, preference_workflow</workflow> <workflow>edit_workflow, preference_interaction_workflow, preference_workflow</workflow>
</chain> </chain>
<chain> <chain>
<type>Property Existence Constraint</type> <type>Property Existence Constraint</type>
...@@ -137,7 +137,7 @@ ...@@ -137,7 +137,7 @@
</chain> </chain>
<chain> <chain>
<type>System Preference</type> <type>System Preference</type>
<workflow>edit_workflow, preference_workflow</workflow> <workflow>edit_workflow, preference_interaction_workflow, preference_workflow</workflow>
</chain> </chain>
<chain> <chain>
<type>TALES Constraint</type> <type>TALES Constraint</type>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="InteractionWorkflowDefinition" module="Products.ERP5.InteractionWorkflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>preference_interaction_workflow</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Interaction" module="Products.ERP5.Interaction"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_mapping</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>interactions</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?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>InteractionWorkflow_clearCache</string>
</list>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Clear cache</string> </value>
</item>
<item>
<key> <string>guard</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>method_id</string> </key>
<value>
<list>
<string>enable</string>
<string>disable</string>
<string>_set.*</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>
<none/>
</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>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Scripts" module="Products.DCWorkflow.Scripts"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_mapping</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>scripts</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>"""Clear the cache.\n
\n
This comment is copy pasted from its previous location:\n
TODO: clear different caches according to the preference priority\n
TODO: (XXX) currently, if one use enables / disables a cache, caches\n
for all other users are reset. This is not good for a system\n
in which users do a lot of preference validation. A better solution\n
is needed for this. But it is not easy because the concept of\n
"per user cache" has been proven to be ambiguous or useless.\n
In theory, a solution could consist in using more keys to\n
select caches or to delete "manually" certain cache keys.\n
"""\n
sci.getPortal().portal_caches.clearCache(cache_factory_list=(\'erp5_ui_short\',))\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>sci</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>InteractionWorkflow_clearCache</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Variables" module="Products.DCWorkflow.Variables"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_mapping</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>variables</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Worklists" module="Products.DCWorkflow.Worklists"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_mapping</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>worklists</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
41091 41092
\ No newline at end of file \ No newline at end of file
...@@ -33,6 +33,7 @@ Mapped Value | edit_workflow ...@@ -33,6 +33,7 @@ Mapped Value | edit_workflow
Memcached Plugin | memcached_plugin_interaction_workflow Memcached Plugin | memcached_plugin_interaction_workflow
Predicate | rule_interaction_workflow Predicate | rule_interaction_workflow
Preference | edit_workflow Preference | edit_workflow
Preference | preference_interaction_workflow
Preference | preference_workflow Preference | preference_workflow
Property Existence Constraint | dynamic_class_generation_interaction_workflow Property Existence Constraint | dynamic_class_generation_interaction_workflow
Property Sheet Tool | dynamic_class_generation_interaction_workflow Property Sheet Tool | dynamic_class_generation_interaction_workflow
...@@ -41,6 +42,7 @@ Property Type Validity Constraint | dynamic_class_generation_interaction_workflo ...@@ -41,6 +42,7 @@ Property Type Validity Constraint | dynamic_class_generation_interaction_workflo
Standard Property | dynamic_class_generation_interaction_workflow Standard Property | dynamic_class_generation_interaction_workflow
String Attribute Match Constraint | dynamic_class_generation_interaction_workflow String Attribute Match Constraint | dynamic_class_generation_interaction_workflow
System Preference | edit_workflow System Preference | edit_workflow
System Preference | preference_interaction_workflow
System Preference | preference_workflow System Preference | preference_workflow
TALES Constraint | dynamic_class_generation_interaction_workflow TALES Constraint | dynamic_class_generation_interaction_workflow
Test Component | component_validation_workflow Test Component | component_validation_workflow
......
...@@ -6,6 +6,7 @@ distributed_ram_cache_interaction_workflow ...@@ -6,6 +6,7 @@ distributed_ram_cache_interaction_workflow
dynamic_class_generation_interaction_workflow dynamic_class_generation_interaction_workflow
edit_workflow edit_workflow
memcached_plugin_interaction_workflow memcached_plugin_interaction_workflow
preference_interaction_workflow
preference_workflow preference_workflow
pricing_interaction_workflow pricing_interaction_workflow
rule_interaction_workflow rule_interaction_workflow
......
...@@ -30,7 +30,6 @@ from AccessControl import ClassSecurityInfo ...@@ -30,7 +30,6 @@ from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet, Constraint from Products.ERP5Type import Permissions, PropertySheet, Constraint
from Products.ERP5Type.Core.Folder import Folder from Products.ERP5Type.Core.Folder import Folder
from Products.CMFCore.utils import getToolByName
from Products.ERP5Form.PreferenceTool import PreferenceTool from Products.ERP5Form.PreferenceTool import PreferenceTool
class Priority: class Priority:
...@@ -66,30 +65,3 @@ class Preference( Folder ): ...@@ -66,30 +65,3 @@ class Preference( Folder ):
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
def _clearCache(self):
"""Clear caches used by methods of this preference
# TODO: clear different caches according to the preference priority
# TODO: (XXX) currently, if one use enables / disables a cache, caches
for all other users are reset. This is not good for a system
in which users do a lot of preference validation. A better solution
is needed for this. But it is not easy because the concept of
"per user cache" has been proven to be ambiguous or useless.
In theory, a solution could consist in using more keys to
select caches or to delete "manually" certain cache keys.
"""
portal_caches = getToolByName(self.getPortalObject(), 'portal_caches')
portal_caches.clearCache(cache_factory_list=('erp5_ui_short',))
def _edit(self, **kw):
"""edit and clear all caches"""
self._clearCache()
Folder._edit(self, **kw)
def enable(self):
"""Workflow method"""
self._clearCache()
def disable(self):
"""Workflow method"""
self._clearCache()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment