[Erp5-report] r11541 - in /erp5/trunk/products/ERP5Type: dtml/ patches/ tests/
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu Nov 30 14:19:56 CET 2006
Author: jerome
Date: Thu Nov 30 14:19:55 2006
New Revision: 11541
URL: http://svn.erp5.org?rev=11541&view=rev
Log:
revert 11483, because erp5_xhtml_style anyway caches the top bar again using the default cache
Modified:
erp5/trunk/products/ERP5Type/dtml/workflow_properties.dtml
erp5/trunk/products/ERP5Type/patches/DCWorkflow.py
erp5/trunk/products/ERP5Type/tests/testCacheTool.py
Modified: erp5/trunk/products/ERP5Type/dtml/workflow_properties.dtml
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/dtml/workflow_properties.dtml?rev=11541&r1=11540&r2=11541&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/dtml/workflow_properties.dtml (original)
+++ erp5/trunk/products/ERP5Type/dtml/workflow_properties.dtml Thu Nov 30 14:19:55 2006
@@ -18,22 +18,6 @@
<th align="left">Description</th>
<td><textarea name="description" rows="5" cols="80">&dtml-description;</textarea></td>
</tr>
-
-<dtml-if "context.portal_caches">
-<tr>
-<th align="left">Worklists Cache</th>
-<td>
- <select name="cache_factory_id" >
- <option value=""/>
- <dtml-in "context.portal_caches.objectItems()">
- <option value="&dtml-sequence-key;"
- <dtml-if "_['sequence-key']==getattr(context, 'cache_factory_id', '')">SELECTED</dtml-if>
- >&dtml-title_or_id;</option>
- </dtml-in>
- </select>
-</td>
-</tr>
-</dtml-if>
<tr>
<th align="left">'Manager' role bypasses guards</th>
Modified: erp5/trunk/products/ERP5Type/patches/DCWorkflow.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/patches/DCWorkflow.py?rev=11541&r1=11540&r2=11541&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/patches/DCWorkflow.py (original)
+++ erp5/trunk/products/ERP5Type/patches/DCWorkflow.py Thu Nov 30 14:19:55 2006
@@ -26,7 +26,6 @@
from DocumentTemplate.DT_Util import TemplateDict
from DateTime import DateTime
from Products.ERP5Type.Cache import CachingMethod
-from Products.ERP5Type.Cache import DEFAULT_CACHE_FACTORY
from Products.ERP5Type.Utils import convertToMixedCase
from string import join
from zLOG import LOG
@@ -37,16 +36,14 @@
from Products.DCWorkflow.WorkflowUIMixin import WorkflowUIMixin as WorkflowUIMixin_class
from Products.DCWorkflow.Guard import Guard
-# patched to add a description on worklist for ERP5 Web, and to add the cache
-# control for worklists
-def WorkflowUIMixin_setProperties( self, title, description='',
- cache_factory_id='', manager_bypass=0, props=None, REQUEST=None):
+def WorkflowUIMixin_setProperties( self, title
+ , description='' # the only addition to WorkflowUIMixin.setProperties
+ , manager_bypass=0, props=None, REQUEST=None):
"""Sets basic properties.
"""
self.title = str(title)
self.description = str(description)
self.manager_bypass = manager_bypass and 1 or 0
- self.cache_factory_id = cache_factory_id
g = Guard()
if g.changeFromProperties(props or REQUEST):
self.creation_guard = g
@@ -60,7 +57,6 @@
WorkflowUIMixin_class.manage_properties = DTMLFile('workflow_properties', _dtmldir)
-DCWorkflowDefinition_listGlobalActions_original = DCWorkflowDefinition.listGlobalActions
def DCWorkflowDefinition_listGlobalActions(self, info):
'''
@@ -69,12 +65,11 @@
Called on every request.
Returns the actions to be displayed to the user.
'''
- if not self.worklists:
- return None # Optimization
-
- portal = self._getPortalRoot()
def _listGlobalActions(user=None, id=None, portal_path=None):
+ if not self.worklists:
+ return None # Optimization
sm = getSecurityManager()
+ portal = self._getPortalRoot()
res = []
fmt_data = None
# We want to display some actions depending on the current date
@@ -101,6 +96,7 @@
if not (guard is None or guard.check(sm, self, portal)):
dict['local_roles'] = guard.roles
# Patch to use ZSQLCatalog and get high speed
+ # LOG("PatchedDCWorkflowDefinition", 0, dict)
searchres_len = int(apply(catalog.countResults, (), dict)[0][0])
if searchres_len == 0:
continue
@@ -125,17 +121,11 @@
res.sort()
return map((lambda (id, val): val), res)
- cache_tool = getToolByName(self, 'portal_caches', None)
- if cache_tool is not None:
- # If we have a cache factory controlling this workflow's worklist cache
- cache_factory = getattr(self, 'cache_factory_id', DEFAULT_CACHE_FACTORY)
- _listGlobalActions = CachingMethod(_listGlobalActions,
- id='%s_listGlobalActions' % self.id,
- cache_factory=cache_factory)
- user = str(_getAuthenticatedUser(self))
- return _listGlobalActions(user=user, portal_path=portal.getPhysicalPath())
- else:
- return DCWorkflowDefinition_listGlobalActions_original(self, info)
+ # Return Cache
+ _listGlobalActions = CachingMethod(_listGlobalActions, id='listGlobalActions', cache_duration = 300)
+ user = str(_getAuthenticatedUser(self))
+ return _listGlobalActions(user=user, id=self.id, portal_path=self._getPortalRoot().getPhysicalPath())
+
DCWorkflowDefinition.listGlobalActions = DCWorkflowDefinition_listGlobalActions
Modified: erp5/trunk/products/ERP5Type/tests/testCacheTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/testCacheTool.py?rev=11541&r1=11540&r2=11541&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/testCacheTool.py (original)
+++ erp5/trunk/products/ERP5Type/tests/testCacheTool.py Thu Nov 30 14:19:55 2006
@@ -282,44 +282,6 @@
## Cache cleared shouldn't be previously cached
self.assert_(1.0 < calculation_time)
- def test_DCWorkflowIntegration(self, quiet=0, run=run_all_test):
- """ Test Wokflow caching DCWorkflow global actions"""
- portal = self.getPortal()
- # set up caching environnement
- ctool = portal.portal_caches
- first_factory = ctool.newContent(portal_type='Cache Factory',
- id='first_factory')
- first_factory_cache = TestingCache({})
- second_factory = ctool.newContent(portal_type='Cache Factory',
- id='second_factory')
- second_factory_cache = TestingCache({})
- # emulate CachingMethod.factories initialization
- CachingMethod.factories['first_factory'] = first_factory_cache
- CachingMethod.factories['second_factory'] = second_factory_cache
-
- # setup two workflows with different cache factories
- wftool = portal.portal_workflow
- wftool.manage_addWorkflow('erp5_workflow (ERP5-style empty workflow)',
- 'first_workflow')
- first_workflow = wftool._getOb('first_workflow')
- first_workflow.cache_factory_id = 'first_factory'
- first_workflow.worklists.addWorklist('dummy_worklist')
-
- wftool.manage_addWorkflow('erp5_workflow (ERP5-style empty workflow)',
- 'second_workflow')
- second_workflow = wftool._getOb('second_workflow')
- second_workflow.cache_factory_id = 'second_factory'
- second_workflow.worklists.addWorklist('dummy_worklist')
-
- # listing actions will use the corresponding cache
- info = wftool._getOAI(ctool)
- first_workflow.listGlobalActions(info)
- self.assertEquals(1, first_factory_cache.getCacheMisses())
- self.assertEquals(0, second_factory_cache.getCacheMisses())
- second_workflow.listGlobalActions(info)
- self.assertEquals(1, first_factory_cache.getCacheMisses())
- self.assertEquals(1, second_factory_cache.getCacheMisses())
-
if __name__ == '__main__':
framework()
else:
More information about the Erp5-report
mailing list