[Checkins] SVN: Products.CMFCore/trunk/Products/CMFCore/ - FiveActionsTool: Removed the tool and all functionality for bridging
Jens Vagelpohl
jens at dataflake.org
Fri Oct 10 11:44:47 EDT 2008
Log message for revision 91988:
- FiveActionsTool: Removed the tool and all functionality for bridging
between Zope 3-style menu items and CMF actions. The CMF has been going
a different route for a long time and the code is unused and
unmaintained.
Changed:
U Products.CMFCore/trunk/Products/CMFCore/CHANGES.txt
U Products.CMFCore/trunk/Products/CMFCore/__init__.py
U Products.CMFCore/trunk/Products/CMFCore/browser/configure.zcml
D Products.CMFCore/trunk/Products/CMFCore/browser/globalbrowsermenuservice.py
D Products.CMFCore/trunk/Products/CMFCore/browser/meta.zcml
D Products.CMFCore/trunk/Products/CMFCore/dtml/explainFiveActionsTool.dtml
D Products.CMFCore/trunk/Products/CMFCore/fiveactionstool.py
U Products.CMFCore/trunk/Products/CMFCore/meta.zcml
D Products.CMFCore/trunk/Products/CMFCore/tests/test_fiveactionstool.py
-=-
Modified: Products.CMFCore/trunk/Products/CMFCore/CHANGES.txt
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/CHANGES.txt 2008-10-10 15:20:32 UTC (rev 91987)
+++ Products.CMFCore/trunk/Products/CMFCore/CHANGES.txt 2008-10-10 15:44:47 UTC (rev 91988)
@@ -4,6 +4,11 @@
2.2.0 (unreleased)
------------------
+- FiveActionsTool: Removed the tool and all functionality for bridging
+ between Zope 3-style menu items and CMF actions. The CMF has been going
+ a different route for a long time and the code is unused and
+ unmaintained.
+
- Actions: Added deprecation warnings to the ZMI actions tab and
most listActions methods where old-style actions are found
asking developers to move to new-style actions instead. These
Modified: Products.CMFCore/trunk/Products/CMFCore/__init__.py
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/__init__.py 2008-10-10 15:20:32 UTC (rev 91987)
+++ Products.CMFCore/trunk/Products/CMFCore/__init__.py 2008-10-10 15:44:47 UTC (rev 91988)
@@ -20,7 +20,6 @@
import ActionsTool, UndoTool, RegistrationTool, SkinsTool
import MemberDataTool, TypesTool
import URLTool
-import fiveactionstool
import DirectoryView, FSImage, FSFile, FSPropertiesObject
import FSDTMLMethod, FSPythonScript
import FSPageTemplate
@@ -52,7 +51,6 @@
MemberDataTool.MemberDataTool,
TypesTool.TypesTool,
URLTool.URLTool,
- fiveactionstool.FiveActionsTool,
)
# BBB: oldstyle constructors
Modified: Products.CMFCore/trunk/Products/CMFCore/browser/configure.zcml
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/browser/configure.zcml 2008-10-10 15:20:32 UTC (rev 91987)
+++ Products.CMFCore/trunk/Products/CMFCore/browser/configure.zcml 2008-10-10 15:44:47 UTC (rev 91988)
@@ -39,10 +39,4 @@
</configure>
- <!-- Set up default menus as action categories. -->
- <browser:menu
- id="object"
- title="Object menu"
- />
-
</configure>
Deleted: Products.CMFCore/trunk/Products/CMFCore/browser/globalbrowsermenuservice.py
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/browser/globalbrowsermenuservice.py 2008-10-10 15:20:32 UTC (rev 91987)
+++ Products.CMFCore/trunk/Products/CMFCore/browser/globalbrowsermenuservice.py 2008-10-10 15:44:47 UTC (rev 91988)
@@ -1,162 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Global Browser Menu Service
-
-Five-based adaptation of the one in Zope 3.0.
-
-$Id$
-"""
-from zope.interface import implementedBy
-from zope.interface.interfaces import IInterface
-from zope.security.interfaces import Unauthorized, Forbidden
-from zope.app.publication.browser import PublicationTraverser
-from zope.app.component.interface import provideInterface
-
-from Products.Five.security import checkPermission, CheckerPublic
-
-from types import ClassType
-
-
-def addMenuItem(menu_id, interface, action, title,
- description='', filter_string=None, permission=None,
- extra=None,
- ):
- from zope.app.publisher.browser.globalbrowsermenuservice import \
- globalBrowserMenuService
- from zope.app.publisher.browser.globalbrowsermenuservice import MenuItem
- registry = globalBrowserMenuService._registry[menu_id].registry
-
- if permission:
- if permission == 'zope.Public':
- permission = CheckerPublic
-
- if interface is not None and not IInterface.providedBy(interface):
- if isinstance(interface, (type, ClassType)):
- interface = implementedBy(interface)
- else:
- raise TypeError(
- "The interface argument must be an interface (or None) "
- "or a class.")
-
- data = registry.get(interface) or []
- data.append(
- MenuItem(action, title, description, filter_string, permission, extra)
- )
- registry.register(interface, data)
-
-
-def getMenu(menu_id, object, request, max=999999):
- from zope.app.publisher.browser.globalbrowsermenuservice import \
- globalBrowserMenuService
- traverser = PublicationTraverser()
-
- result = []
- seen = {}
-
- # stuff for figuring out the selected view
- request_url = request.getURL()
-
- for item in globalBrowserMenuService.getAllMenuItems(menu_id, object):
-
- # Make sure we don't repeat a specification for a given title
- title = item.title
- if title in seen:
- continue
- seen[title] = 1
-
- permission = item.permission
- action = item.action
-
- if permission:
- # If we have an explicit permission, check that we
- # can access it.
- if not checkPermission(permission, object):
- continue
-
- elif action:
- # Otherwise, test access by attempting access
- path = action
- l = action.find('?')
- if l >= 0:
- path = action[:l]
- try:
- v = traverser.traverseRelativeURL(
- request, object, path)
- # TODO:
- # tickle the security proxy's checker
- # we're assuming that view pages are callable
- # this is a pretty sound assumption
- v.__call__
- except (Unauthorized, Forbidden):
- continue # Skip unauthorized or forbidden
-
- normalized_action = action
- if action.startswith('@@'):
- normalized_action = action[2:]
-
- if request_url.endswith('/'+normalized_action):
- selected='selected'
- elif request_url.endswith('/++view++'+normalized_action):
- selected='selected'
- elif request_url.endswith('/@@'+normalized_action):
- selected='selected'
- else:
- selected=''
-
- result.append({
- 'title': title,
- 'description': item.description,
- 'action': "%s" % action,
- 'filter': item.filter,
- 'selected': selected,
- 'extra': item.extra,
- })
-
- if len(result) >= max:
- return result
-
- return result
-
-
-
-def menuItemDirective(_context, menu, for_,
- action, title, description='', filter=None,
- permission=None, extra=None):
- return menuItemsDirective(_context, menu, for_).menuItem(
- _context, action, title, description, filter, permission, extra)
-
-
-class menuItemsDirective(object):
-
- def __init__(self, _context, menu, for_):
- self.interface = for_
- self.menu = menu
-
- def menuItem(self, _context, action, title, description='',
- filter=None, permission=None, extra=None):
- _context.action(
- discriminator = ('browser:menuItem',
- self.menu, self.interface, title),
- callable = addMenuItem,
- args = (self.menu, self.interface,
- action, title, description, filter, permission, extra),
- ),
-
- def __call__(self, _context):
- _context.action(
- discriminator = None,
- callable = provideInterface,
- args = (self.interface.__module__+'.'+self.interface.getName(),
- self.interface)
- )
Deleted: Products.CMFCore/trunk/Products/CMFCore/browser/meta.zcml
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/browser/meta.zcml 2008-10-10 15:20:32 UTC (rev 91987)
+++ Products.CMFCore/trunk/Products/CMFCore/browser/meta.zcml 2008-10-10 15:44:47 UTC (rev 91988)
@@ -1,36 +0,0 @@
-<configure
- xmlns="http://namespaces.zope.org/zope"
- xmlns:meta="http://namespaces.zope.org/meta">
-
- <!-- Commenting out pending Lennart's fixes for Zope 3.2 compatibility.
- <meta:directives namespace="http://namespaces.zope.org/cmf">
-
- <meta:directive
- name="menu"
- schema="zope.app.publisher.browser.metadirectives.IMenuDirective"
- handler="zope.app.publisher.browser.globalbrowsermenuservice.menuDirective"
- />
-
- <meta:directive
- name="menuItem"
- schema="zope.app.publisher.browser.metadirectives.IMenuItemDirective"
- handler=".browser.globalbrowsermenuservice.menuItemDirective"
- />
-
- <meta:complexDirective
- name="menuItems"
- schema="zope.app.publisher.browser.metadirectives.IMenuItemsDirective"
- handler=".browser.globalbrowsermenuservice.menuItemsDirective"
- >
-
- <meta:subdirective
- name="menuItem"
- schema="zope.app.publisher.browser.metadirectives.IMenuItemSubdirective"
- />
-
- </meta:complexDirective>
-
- </meta:directives>
- -->
-
-</configure>
Deleted: Products.CMFCore/trunk/Products/CMFCore/dtml/explainFiveActionsTool.dtml
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/dtml/explainFiveActionsTool.dtml 2008-10-10 15:20:32 UTC (rev 91987)
+++ Products.CMFCore/trunk/Products/CMFCore/dtml/explainFiveActionsTool.dtml 2008-10-10 15:44:47 UTC (rev 91988)
@@ -1,8 +0,0 @@
-<dtml-var manage_page_header>
-<dtml-var manage_tabs>
-
-<h3><code>portal_fiveactions</code> Tool</h3>
-
-<p>This tool provides a bridge from Zope 3 menus to CMF actions.</p>
-
-<dtml-var manage_page_footer>
Deleted: Products.CMFCore/trunk/Products/CMFCore/fiveactionstool.py
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/fiveactionstool.py 2008-10-10 15:20:32 UTC (rev 91987)
+++ Products.CMFCore/trunk/Products/CMFCore/fiveactionstool.py 2008-10-10 15:44:47 UTC (rev 91988)
@@ -1,94 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-""" Five actions tool.
-
-$Id$
-"""
-
-from AccessControl import ClassSecurityInfo
-from Globals import InitializeClass
-from OFS.SimpleItem import SimpleItem
-from zope.app.publisher.browser.menu import getMenu
-from zope.app.publisher.interfaces.browser import IBrowserMenu
-from zope.component import getUtilitiesFor
-
-from Products.CMFCore.ActionInformation import ActionInformation
-from Products.CMFCore.ActionProviderBase import ActionProviderBase
-from Products.CMFCore.Expression import Expression
-from Products.CMFCore.utils import UniqueObject
-
-def _listMenuIds():
- return [id for id, utility in getUtilitiesFor(IBrowserMenu)]
-
-
-class FiveActionsTool( UniqueObject, SimpleItem, ActionProviderBase ):
-
- """ Links content to discussions.
- """
-
- id = 'portal_fiveactions'
- meta_type = 'Five Actions Tool'
-
- security = ClassSecurityInfo()
-
- def getRequestURL(self):
- return self.REQUEST.URL
-
- security.declarePrivate('listActions')
- def listActions(self, info=None, object=None):
- """ List all the actions defined by a provider.
- """
- if object is None:
- if info is None:
- # There is no support for global actions
- return ()
- else:
- object = info.content
-
- actions = []
- for menu_id in _listMenuIds():
- for entry in getMenu(menu_id, object, self.REQUEST):
- # The action needs a unique name, so I'll build one
- # from the object_id and the action url. That is sure
- # to be unique.
- action = str(entry['action'])
- if object is None:
- act_id = 'action_%s' % action
- else:
- act_id = 'action_%s_%s' % (object.getId(), action)
-
- if entry.get('filter') is None:
- filter = None
- else:
- filter = Expression(text=str(entry['filter']))
-
- title = entry['title']
- # Having bits of unicode here can make rendering very confused,
- # so we convert it to plain strings, but NOT if it is a
- # messageID. In Zope 3.2 there are two types of messages,
- # Message and MessageID, where MessageID is depracated. We can
- # type-check for both but that provokes a deprecation warning,
- # so we check for the "domain" attribute instead.
- if not hasattr(title, 'domain'):
- title = str(title)
- act = ActionInformation(id=act_id,
- title=title,
- action=Expression(text='string:%s' % action),
- condition=filter,
- category=str(menu_id),
- visible=1)
- actions.append(act)
-
- return tuple(actions)
-
-InitializeClass( FiveActionsTool )
Modified: Products.CMFCore/trunk/Products/CMFCore/meta.zcml
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/meta.zcml 2008-10-10 15:20:32 UTC (rev 91987)
+++ Products.CMFCore/trunk/Products/CMFCore/meta.zcml 2008-10-10 15:44:47 UTC (rev 91988)
@@ -2,8 +2,6 @@
xmlns="http://namespaces.zope.org/zope"
xmlns:meta="http://namespaces.zope.org/meta">
- <include file="browser/meta.zcml"/>
-
<meta:directive
name="registerDirectory"
namespace="http://namespaces.zope.org/cmf"
Deleted: Products.CMFCore/trunk/Products/CMFCore/tests/test_fiveactionstool.py
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/tests/test_fiveactionstool.py 2008-10-10 15:20:32 UTC (rev 91987)
+++ Products.CMFCore/trunk/Products/CMFCore/tests/test_fiveactionstool.py 2008-10-10 15:44:47 UTC (rev 91988)
@@ -1,113 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-""" Unit tests for five actions tool.
-
-$Id$
-"""
-
-import unittest
-from Testing import ZopeTestCase
-
-
-def test_fiveactionstool():
- """
- Test the Five actions tool.
-
- Some basic setup:
-
- >>> import Products.Five
- >>> import Products.CMFCore
- >>> from Products.Five import zcml
- >>> zcml.load_config('meta.zcml', Products.Five)
- >>> zcml.load_config('permissions.zcml', Products.Five)
- >>> zcml.load_config('meta.zcml', Products.CMFCore)
- >>> folder = self.folder
-
- For menus to work, the request must have defaultSkin.
-
- >>> from zope.publisher.browser import setDefaultSkin
- >>> setDefaultSkin(self.folder.REQUEST)
-
- We need to make Zope 3 use Zope 2s security policy
-
- >>> from zope.security.management import thread_local
- >>> thread_local.interaction = None
- >>> from Products.Five.security import newInteraction
- >>> newInteraction()
-
- Log in as manager
-
- >>> uf = self.folder.acl_users
- >>> uf._doAddUser('manager', 'r00t', ['Manager'], [])
- >>> self.login('manager')
-
- Let's create a Five actions tool:
-
- >>> from Products.CMFCore.fiveactionstool import FiveActionsTool
- >>> folder.tool = FiveActionsTool()
- >>> tool = folder.tool # rewrap
-
- Let's create some simple content object providing ISimpleContent:
-
- >>> from Products.Five.tests.testing.simplecontent import SimpleContent
- >>> id = self.folder._setObject('foo', SimpleContent('foo', 'Foo'))
- >>> foo = self.folder.foo
-
- Now we'll load a configuration file specifying some menu and menu
- items for ISimpleContent.
-
- >>> import Products.CMFCore.tests
- >>> zcml.load_config('fiveactions.zcml', Products.CMFCore.tests)
-
- Let's look what the tool lists as actions for such an object.
-
- >>> actions = tool.listActions(object=foo)
- >>> [(action.category, action.id) for action in actions]
- [('mymenu', 'action_foo_public.html'), ('mymenu', 'action_foo_protected.html')]
-
- But if we log in as a user who is not manager, we should not get the
- protected menu item, , as it was protected by a more restrictive permission:
-
- >>> uf = self.folder.acl_users
- >>> uf._doAddUser('user', 'user', [], [])
- >>> self.login('user')
-
- >>> actions = tool.listActions(object=foo)
- >>> [(action.category, action.id) for action in actions]
- [('mymenu', 'action_foo_public.html')]
-
- When looking at an object not implementing ISimpleContent, we see no
- actions:
-
- >>> tool.listActions(object=folder)
- ()
-
- The tool itself doesn't have any actions:
-
- >>> tool.listActions()
- ()
-
- Cleanup:
-
- >>> from zope.testing.cleanup import cleanUp
- >>> cleanUp()
- """
-
-
-def test_suite():
- return unittest.TestSuite((
- ZopeTestCase.ZopeDocTestSuite(),
- ))
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
More information about the Checkins
mailing list