[Zope3-checkins]
SVN: Zope3/trunk/src/zope/app/container/browser/tests/test_adding.py
The Browser Menu Service is gone.
Stephan Richter
srichter at cosmos.phy.tufts.edu
Thu Sep 23 10:47:39 EDT 2004
Log message for revision 27653:
The Browser Menu Service is gone.
Use new API to create menu items.
D src/zope/app/publisher/browser/globalbrowsermenuservice.py
D src/zope/app/publisher/browser/tests/test_globalbrowsermenuservicedirectives.py
The Browser Menu Service is gone.
A src/zope/app/publisher/browser/menu.py
M src/zope/app/publisher/interfaces/browser.py
M src/zope/app/publisher/browser/metaconfigure.py
M src/zope/app/publisher/browser/configure.zcml
M src/zope/app/publisher/browser/meta.zcml
A src/zope/app/publisher/browser/fields.py
M src/zope/app/publisher/browser/managementviewselector.py
M src/zope/app/publisher/browser/metadirectives.py
M src/zope/app/publisher/browser/tests/test_addMenuItem.py
M src/zope/app/publisher/browser/tests/test_directives.py
A src/zope/app/publisher/browser/tests/test_menu.py
A src/zope/app/publisher/browser/tests/menus.zcml
A src/zope/app/publisher/browser/tests/test_fields.py
D src/zope/app/publisher/browser/tests/test_globalbrowsermenuservice.py
D src/zope/app/publisher/browser/tests/test_menuaccessview.py
A src/zope/app/publisher/browser/tests/test_menudirectives.py
The Browser Menu Service is gone.
The new implementation of menus, which uses subscribers, can now be found in
zope.app.publisher.browser.menu. The internals of the new code are pretty much
the same, except that the code has been reorganized.
Changed:
U Zope3/trunk/src/zope/app/container/browser/tests/test_adding.py
-=-
Modified: Zope3/trunk/src/zope/app/container/browser/tests/test_adding.py
===================================================================
--- Zope3/trunk/src/zope/app/container/browser/tests/test_adding.py 2004-09-23 14:47:37 UTC (rev 27652)
+++ Zope3/trunk/src/zope/app/container/browser/tests/test_adding.py 2004-09-23 14:47:39 UTC (rev 27653)
@@ -16,15 +16,17 @@
$Id$
"""
import unittest
-from zope.testing.doctestunit import DocTestSuite
+import zope.interface
+import zope.security.checker
from zope.component.interfaces import IFactory
from zope.component.exceptions import ComponentLookupError
-import zope.interface
from zope.interface import implements, Interface, directlyProvides
from zope.publisher.browser import TestRequest
-import zope.security.checker
+from zope.publisher.interfaces.browser import IBrowserRequest
from zope.security.interfaces import ForbiddenAttribute
+from zope.testing.doctestunit import DocTestSuite
+
from zope.app import zapi
from zope.app.tests import ztapi
from zope.app.tests.placelesssetup import PlacelessSetup, setUp, tearDown
@@ -32,6 +34,8 @@
from zope.app.traversing.interfaces import IContainmentRoot
from zope.app.exception.interfaces import UserError
from zope.app.publisher.browser import BrowserView
+from zope.app.publisher.interfaces.browser import AddMenu
+from zope.app.publisher.browser.menu import BrowserMenuItem
from zope.app.container.interfaces import IAdding
from zope.app.container.interfaces import IObjectAddedEvent
from zope.app.container.interfaces import IContainerNamesContainer
@@ -81,7 +85,14 @@
url += '/' + name
return url
+def defineMenuItem(menuItemType, for_, action, title=u'', extra=None):
+ newclass = type(title, (BrowserMenuItem,),
+ {'title':title, 'action':action,
+ '_for': for_, 'extra':extra})
+ zope.interface.classImplements(newclass, menuItemType)
+ ztapi.subscribe((for_, IBrowserRequest), menuItemType, newclass)
+
class Test(PlacelessSetup, unittest.TestCase):
def setUp(self):
@@ -192,25 +203,16 @@
def test_constraint_driven_addingInfo():
"""
>>> setUp()
- >>> serviceService = zapi.getGlobalServices()
- >>> from zope.app.publisher.interfaces.browser import IBrowserMenuService
- >>> serviceService.defineService(zapi.servicenames.BrowserMenu,
- ... IBrowserMenuService)
- >>> from zope.app.publisher.browser.globalbrowsermenuservice """ \
- """import globalBrowserMenuService
- >>> serviceService.provideService(zapi.servicenames.BrowserMenu,
- ... globalBrowserMenuService)
- >>> menuService = zapi.getGlobalService(zapi.servicenames.BrowserMenu)
- >>> menuService.menu('test', '')
- >>> menuService.menuItem('test', IAdding, '', 'item1', None)
- >>> menuService.menuItem('test', IAdding, '', 'item2', None)
- >>> menuService.menu('zope.app.container.add', '')
- >>> menuService.menuItem('zope.app.container.add', IAdding, '', 'item3',
- ... None, extra={'factory': 'f1'})
- >>> menuService.menuItem('zope.app.container.add', IAdding, '', 'item4',
- ... None, extra={'factory': 'f2'})
+ >>> class TestMenu(zope.interface.Interface):
+ ... pass
+ >>> defineMenuItem(TestMenu, IAdding, '', 'item1')
+ >>> defineMenuItem(TestMenu, IAdding, '', 'item2')
+
+ >>> defineMenuItem(AddMenu, IAdding, '', 'item3', extra={'factory': 'f1'})
+ >>> defineMenuItem(AddMenu, IAdding, '', 'item4', extra={'factory': 'f2'})
+
>>> class F1(object):
... pass
@@ -247,7 +249,7 @@
>>> items[0]['title']
'item3'
- >>> adding.menu_id = 'test'
+ >>> adding.menu_id = TestMenu
>>> items = adding.addingInfo()
>>> len(items)
3
@@ -395,20 +397,8 @@
the container contains only a single content object
>>> setUp()
- >>> serviceService = zapi.getGlobalServices()
- >>> from zope.app.publisher.interfaces.browser import IBrowserMenuService
- >>> serviceService.defineService(zapi.servicenames.BrowserMenu,
- ... IBrowserMenuService)
- >>> from zope.app.publisher.browser.globalbrowsermenuservice """ \
- """import globalBrowserMenuService
- >>> serviceService.provideService(zapi.servicenames.BrowserMenu,
- ... globalBrowserMenuService)
+ >>> defineMenuItem(AddMenu, IAdding, '', 'item3', extra={'factory': 'f1'})
- >>> menuService = zapi.getGlobalService(zapi.servicenames.BrowserMenu)
- >>> menuService.menu('zope.app.container.add', '')
- >>> menuService.menuItem('zope.app.container.add', IAdding, '', 'item3',
- ... None, extra={'factory': 'f1'})
-
>>> class F1(object):
... pass
@@ -466,19 +456,7 @@
implement IContainerNamesContainer
>>> setUp()
- >>> serviceService = zapi.getGlobalServices()
- >>> from zope.app.publisher.interfaces.browser import IBrowserMenuService
- >>> serviceService.defineService(zapi.servicenames.BrowserMenu,
- ... IBrowserMenuService)
- >>> from zope.app.publisher.browser.globalbrowsermenuservice """ \
- """import globalBrowserMenuService
- >>> serviceService.provideService(zapi.servicenames.BrowserMenu,
- ... globalBrowserMenuService)
-
- >>> menuService = zapi.getGlobalService(zapi.servicenames.BrowserMenu)
- >>> menuService.menu('zope.app.container.add', '')
- >>> menuService.menuItem('zope.app.container.add', None, '', 'item3',
- ... None, extra={'factory': ''})
+ >>> defineMenuItem(AddMenu, None, '', 'item3', extra={'factory': ''})
>>> class F1(object):
... pass
@@ -533,22 +511,9 @@
This test checks for whether there is a single content that can be added
and the container uses IContainerNamesContaienr
-
>>> setUp()
- >>> serviceService = zapi.getGlobalServices()
- >>> from zope.app.publisher.interfaces.browser import IBrowserMenuService
- >>> serviceService.defineService(zapi.servicenames.BrowserMenu,
- ... IBrowserMenuService)
- >>> from zope.app.publisher.browser.globalbrowsermenuservice \
- import globalBrowserMenuService
- >>> serviceService.provideService(zapi.servicenames.BrowserMenu,
- ... globalBrowserMenuService)
+ >>> defineMenuItem(AddMenu, None, '', 'item3', extra={'factory': ''})
- >>> menuService = zapi.getGlobalService(zapi.servicenames.BrowserMenu)
- >>> menuService.menu('zope.app.container.add', '')
- >>> menuService.menuItem('zope.app.container.add', None, '', 'item3',
- ... None, extra={'factory': ''})
-
>>> class F1(object):
... pass
More information about the Zope3-Checkins
mailing list