[CMF-checkins] CVS: Products/CMFCore -
ActionInformation.py:1.26.2.2.2.1 ActionProviderBase.py:1.30.2.2.2.1
ActionsTool.py:1.51.2.1.2.1 DiscussionTool.py:1.17.2.2.2.1
Expression.py:1.9.2.1.2.1 WorkflowTool.py:1.46.2.4.2.1
Tres Seaver
tseaver at zope.com
Wed Apr 20 00:35:08 EDT 2005
Update of /cvs-repository/Products/CMFCore
In directory cvs.zope.org:/tmp/cvs-serv15029/CMFCore
Modified Files:
Tag: tseaver-tune_listFilteredActionsFor-branch
ActionInformation.py ActionProviderBase.py ActionsTool.py
DiscussionTool.py Expression.py WorkflowTool.py
Log Message:
- Noodling at reducing the absurd amount of time taken in 'listFilteredActionsFor' (on a branch for safety).
=== Products/CMFCore/ActionInformation.py 1.26.2.2 => 1.26.2.2.2.1 ===
--- Products/CMFCore/ActionInformation.py:1.26.2.2 Wed Mar 16 06:33:52 2005
+++ Products/CMFCore/ActionInformation.py Wed Apr 20 00:34:37 2005
@@ -55,7 +55,7 @@
else:
self._action = action
UserDict.__init__( self, action.getMapping() )
- self.data['name'] = self.data['title']
+ self.title = self.data['name'] = self.data['title']
del self.data['description']
if self.data['action']:
@@ -104,6 +104,8 @@
""" Get the result of the URL expression in the current context.
"""
return self._action._getActionObject()(self._ec)
+
+ url = _getURL
def _checkCondition(self):
""" Check condition expression in the current context.
=== Products/CMFCore/ActionProviderBase.py 1.30.2.2 => 1.30.2.2.2.1 ===
--- Products/CMFCore/ActionProviderBase.py:1.30.2.2 Wed Mar 16 06:33:52 2005
+++ Products/CMFCore/ActionProviderBase.py Wed Apr 20 00:34:37 2005
@@ -77,11 +77,12 @@
security.declarePublic('listActionInfos')
def listActionInfos(self, action_chain=None, object=None,
check_visibility=1, check_permissions=1,
- check_condition=1, max=-1):
+ check_condition=1, max=-1, ec=None):
# List ActionInfo objects.
# (method is without docstring to disable publishing)
#
- ec = getExprContext(self, object)
+ if ec is None:
+ ec = getExprContext(self, object)
actions = self.listActions(object=object)
actions = [ ActionInfo(action, ec) for action in actions ]
=== Products/CMFCore/ActionsTool.py 1.51.2.1 => 1.51.2.1.2.1 ===
--- Products/CMFCore/ActionsTool.py:1.51.2.1 Mon Apr 11 06:43:11 2005
+++ Products/CMFCore/ActionsTool.py Wed Apr 20 00:34:37 2005
@@ -16,6 +16,7 @@
"""
from warnings import warn
+from time import time
from AccessControl import ClassSecurityInfo
from Acquisition import aq_base
@@ -36,7 +37,7 @@
from utils import _dtmldir
from utils import SimpleItemWithProperties
from utils import UniqueObject
-
+from utils import getToolByName
class ActionsTool(UniqueObject, Folder, ActionProviderBase):
"""
@@ -149,13 +150,44 @@
def listFilteredActionsFor(self, object=None):
""" List all actions available to the user.
"""
+ #cache = None
+ #cache_mgr = getToolByName(self, 'portal_actionscache', None)
+
+ #if cache_mgr is not None:
+ # cache = cache_mgr.ZCacheManager_getCache()
+
+ #if cache is not None:
+ # pm = getToolByName(self, 'portal_membership')
+ # if object is None:
+ # object_url = ''
+ # else:
+ # object_url = object.absolute_url()
+ # if pm.isAnonymousUser():
+ # member = None
+ # else:
+ # member = pm.getAuthenticatedMember()
+ # # Prepare a cache key.
+ # keyset = {'object_url': object_url,
+ # 'member': member,
+ # }
+ # result = cache.ZCache_get(ob=self, keywords=keyset)
+ # if result is not None:
+ # # Got a cached value.
+ # return result
+
actions = []
+ ec = getExprContext(self, object)
# Include actions from specific tools.
for provider_name in self.listActionProviders():
provider = getattr(self, provider_name)
if IActionProvider.isImplementedBy(provider):
- actions.extend( provider.listActionInfos(object=object) )
+ start = time()
+ actions.extend( provider.listActionInfos(object=object,
+ ec=ec) )
+ stop = time()
+ open( '/tmp/provider_times', 'a' ).write(
+ '%-20s: %8.3f\n' % (provider_name, (stop-start)*1000) )
else:
# for Action Providers written for CMF versions before 1.5
actions.extend( self._listActionInfos(provider, object) )
@@ -181,12 +213,27 @@
catlist = filtered_actions.setdefault(action['category'], [])
catlist.append(action)
+ #if cache is not None:
+ # result = cache.ZCache_set(ob=self, data=filtered_actions,
+ # keywords=keyset)
return filtered_actions
# listFilteredActions() is an alias.
security.declarePublic('listFilteredActions')
listFilteredActions = listFilteredActionsFor
+ security.declarePrivate('ZCacheable_getModTime')
+ def ZCacheable_getModTime(self, mtime_func=None):
+ '''Returns the highest of the last mod times.'''
+ # Based on:
+ # mtime_func
+ # self.mtime
+ # self.__class__.mtime
+ # (if in a ZClass) zclass_instance.mtime
+ # zclass_instance.__class__.mtime
+ mtime = mtime_func and mtime_func() or 0
+ base = aq_base(self)
+ return max(getattr(base, '_p_mtime', mtime), mtime)
#
# Helper method for backwards compatibility
#
=== Products/CMFCore/DiscussionTool.py 1.17.2.2 => 1.17.2.2.2.1 ===
--- Products/CMFCore/DiscussionTool.py:1.17.2.2 Wed Mar 16 06:33:52 2005
+++ Products/CMFCore/DiscussionTool.py Wed Apr 20 00:34:37 2005
@@ -159,9 +159,13 @@
security.declarePrivate('listActions')
def listActions(self, info=None, object=None):
# Return actions for reply and show replies
- if object is not None or info is None:
+ if object is None and info is None:
+ return ()
+ if info is None:
info = getOAI(self, object)
- content = info.object
+ if object is None:
+ object = info.object
+ content = object
if content is None or not self.isDiscussionAllowedFor(content):
return ()
=== Products/CMFCore/Expression.py 1.9.2.1 => 1.9.2.1.2.1 ===
--- Products/CMFCore/Expression.py:1.9.2.1 Fri Sep 3 13:18:18 2004
+++ Products/CMFCore/Expression.py Wed Apr 20 00:34:37 2005
@@ -90,21 +90,25 @@
else:
object_url = object.absolute_url()
if pm.isAnonymousUser():
- member = None
+ member = member_folder = member_url = None
else:
member = pm.getAuthenticatedMember()
+ member_folder = pm.getHomeFolder()
+ member_url = member_folder and member_folder.absolute_url() or None
data = {
- 'object_url': object_url,
- 'folder_url': folder.absolute_url(),
- 'portal_url': portal.absolute_url(),
- 'object': object,
- 'folder': folder,
- 'portal': portal,
- 'nothing': None,
- 'request': getattr( object, 'REQUEST', None ),
- 'modules': SecureModuleImporter,
- 'member': member,
- 'here': object,
+ 'object_url': object_url,
+ 'folder_url': folder.absolute_url(),
+ 'portal_url': portal.absolute_url(),
+ 'object': object,
+ 'folder': folder,
+ 'portal': portal,
+ 'nothing': None,
+ 'request': getattr( object, 'REQUEST', None ),
+ 'modules': SecureModuleImporter,
+ 'member': member,
+ 'member_folder': member_folder,
+ 'member_url': member_url,
+ 'here': object,
}
return getEngine().getContext(data)
=== Products/CMFCore/WorkflowTool.py 1.46.2.4 => 1.46.2.4.2.1 ===
--- Products/CMFCore/WorkflowTool.py:1.46.2.4 Wed Apr 13 03:23:29 2005
+++ Products/CMFCore/WorkflowTool.py Wed Apr 20 00:34:37 2005
@@ -227,8 +227,10 @@
o Global actions are supplied by all workflows.
"""
- if object is not None or info is None:
+ if info is None:
info = getOAI(self, object)
+ if object is None:
+ object = info.object
chain = self.getChainFor(info.object)
did = {}
actions = []
More information about the CMF-checkins
mailing list