[Erp5-report] r11126 - in /erp5/trunk/products: ERP5/bootstrap/erp5_core/WorkflowTemplateIt...

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Nov 6 16:04:23 CET 2006


Author: jerome
Date: Mon Nov  6 16:04:18 2006
New Revision: 11126

URL: http://svn.erp5.org?rev=11126&view=rev
Log:
Preference now clear the cache automatically when edited and when the workflow state change.


Modified:
    erp5/trunk/products/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/preference_workflow/scripts/disableOtherPreferences.xml
    erp5/trunk/products/ERP5/bootstrap/erp5_core/bt/revision
    erp5/trunk/products/ERP5Form/Document/Preference.py
    erp5/trunk/products/ERP5Form/tests/testPreferences.py

Modified: erp5/trunk/products/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/preference_workflow/scripts/disableOtherPreferences.xml
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/preference_workflow/scripts/disableOtherPreferences.xml?rev=11126&r1=11125&r2=11126&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/preference_workflow/scripts/disableOtherPreferences.xml (original)
+++ erp5/trunk/products/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/preference_workflow/scripts/disableOtherPreferences.xml Mon Nov  6 16:04:18 2006
@@ -68,8 +68,7 @@
         </item>
         <item>
             <key> <string>_body</string> </key>
-            <value> <string>from Products.ERP5Type.Cache import clearCache\n
-from Products.ERP5Type.Message import Message\n
+            <value> <string>from Products.ERP5Type.Message import Message\n
 \n
 pref = sci.object\n
 portal = sci.getPortal()\n
@@ -91,8 +90,6 @@
                                    mapping={\'preference_title\': context.getTitle()}) )\n
   except \'Unauthorized\', a :\n
     LOG("not authorized to deactivate %s"%p)\n
-\n
-clearCache(method_id="PreferenceTool.CachingMethod.")\n
 </string> </value>
         </item>
         <item>

Modified: erp5/trunk/products/ERP5/bootstrap/erp5_core/bt/revision
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/bootstrap/erp5_core/bt/revision?rev=11126&r1=11125&r2=11126&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/bootstrap/erp5_core/bt/revision (original)
+++ erp5/trunk/products/ERP5/bootstrap/erp5_core/bt/revision Mon Nov  6 16:04:18 2006
@@ -1,1 +1,1 @@
-155
+156

Modified: erp5/trunk/products/ERP5Form/Document/Preference.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Form/Document/Preference.py?rev=11126&r1=11125&r2=11126&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Form/Document/Preference.py (original)
+++ erp5/trunk/products/ERP5Form/Document/Preference.py Mon Nov  6 16:04:18 2006
@@ -30,6 +30,7 @@
 
 from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
 from Products.ERP5Type.Document.Folder import Folder
+from Products.ERP5Type.Cache import clearCache
 
 class Priority:
   """ names for priorities """
@@ -63,3 +64,22 @@
   security = ClassSecurityInfo()
   security.declareObjectProtected(Permissions.AccessContentsInformation)
 
+  def _clearCache(self):
+    """Clear caches used by methods of this preference
+    # TODO: clear different caches according to the preference priority
+    """
+    clearCache()
+
+  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()
+  

Modified: erp5/trunk/products/ERP5Form/tests/testPreferences.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Form/tests/testPreferences.py?rev=11126&r1=11125&r2=11126&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Form/tests/testPreferences.py (original)
+++ erp5/trunk/products/ERP5Form/tests/testPreferences.py Mon Nov  6 16:04:18 2006
@@ -173,14 +173,12 @@
     self.assertEquals(
       site.getPreferredAccountingTransactionSimulationState(), None)
 
-    from Products.ERP5Type.Cache import clearCache
-    clearCache()
     self.assertEquals(len(pref_tool.getPreference(
       'preferred_accounting_transaction_simulation_state_list')), 0)
     
-    site.setPreferredAccountingTransactionSimulationStateList(
-            ['stopped', 'delivered'])
-    clearCache() # FIXME: the cache should be cleared automatically
+    site.edit(
+      preferred_accounting_transaction_simulation_state_list=
+      ['stopped', 'delivered'])
     self.assertEquals(list(pref_tool.getPreference(
       'preferred_accounting_transaction_simulation_state_list')),
       list(site.getPreferredAccountingTransactionSimulationStateList()))
@@ -193,22 +191,20 @@
       self.assertEquals(pref_tool.getPreference(prop),
                         site.getProperty(prop))
     
-    group.setPreferredAccountingTransactionSimulationStateList(['draft'])
-    clearCache()
+    group.edit(
+      preferred_accounting_transaction_simulation_state_list=['draft'])
     self.assertEquals(list(pref_tool.getPreference(
       'preferred_accounting_transaction_simulation_state_list')),
       list(group.getPreferredAccountingTransactionSimulationStateList()))
     
-    person1.setPreferredAccountingTransactionSimulationStateList(
+    person1.edit(preferred_accounting_transaction_simulation_state_list=
               ['cancelled'])
-    clearCache()
     self.assertEquals(list(pref_tool.getPreference(
       'preferred_accounting_transaction_simulation_state_list')),
       list(person1.getPreferredAccountingTransactionSimulationStateList()))
     # disable person -> group is selected
     self.getWorkflowTool().doActionFor(person1,
             'disable_action', wf_id='preference_workflow')
-    clearCache()
     self.assertEquals(list(pref_tool.getPreference(
       'preferred_accounting_transaction_simulation_state_list')),
       list(group.getPreferredAccountingTransactionSimulationStateList()))




More information about the Erp5-report mailing list