[CMF-checkins] SVN: CMF/trunk/CMFCore/fiveactionstool.py Collector
#392: work around Zope 2.9-induced import errors in fiveactionstool
Tres Seaver
tseaver at palladion.com
Sat Nov 5 17:32:40 EST 2005
Log message for revision 39939:
Collector #392: work around Zope 2.9-induced import errors in fiveactionstool
o The tests for that module still aren't passing against the Zope2 trunk.
o CMFCore/browser/configure.zcml is busted on 2.9 as well, due to the fact
that globalbrowsermenu is not BBB-enabled in Zope 3.2.
Changed:
U CMF/trunk/CMFCore/fiveactionstool.py
-=-
Modified: CMF/trunk/CMFCore/fiveactionstool.py
===================================================================
--- CMF/trunk/CMFCore/fiveactionstool.py 2005-11-05 21:39:56 UTC (rev 39938)
+++ CMF/trunk/CMFCore/fiveactionstool.py 2005-11-05 22:32:39 UTC (rev 39939)
@@ -27,11 +27,23 @@
from utils import UniqueObject
from utils import _dtmldir
-from zope.app.publisher.browser.globalbrowsermenuservice import \
- globalBrowserMenuService
-from browser.globalbrowsermenuservice import getMenu
+try: # BBB (actually, FFF ;)
+ from zope.app.publisher.browser.globalbrowsermenuservice import \
+ globalBrowserMenuService
+except ImportError: # Zope3 > 3.0 loses services
+ from zope.app import zapi
+ from zope.app.publisher.interfaces.browser import IBrowserMenu
+ from zope.app.publisher.browser.menu import getMenu
+ def _listMenuIds():
+ return zapi.getUtilitiesFor(IBrowserMenu)
+else:
+ from zope.app.browser.globalbrowsermenuservice import getMenu
+ def _listMenuIds():
+ return globalBrowserMenuService._registry.keys()
+
+
class FiveActionsTool(UniqueObject, SimpleItem, ActionProviderBase):
"""Five actions tool.
@@ -73,9 +85,9 @@
return ()
actions = []
- for mid in globalBrowserMenuService._registry.keys():
- menu = getMenu(mid, object, self.REQUEST)
- for entry in menu:
+
+ for menu_id in _listMenuIds():
+ for entry in getMenu(menu_id, object, self.REQUEST):
# The action needs a unique name, so we'll build one
# from the object_id and the action url. That is sure
# to be unique.
@@ -94,9 +106,10 @@
title=str(entry['title']),
action=Expression(text='string:%s' % action),
condition=filter,
- category=str(mid),
+ category=str(menu_id),
visible=1)
actions.append(act)
+
return tuple(actions)
More information about the CMF-checkins
mailing list