[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/container/browser/ The Browser Menu Service is gone.

Stephan Richter srichter at cosmos.phy.tufts.edu
Thu Sep 23 10:47:37 EDT 2004


Log message for revision 27652:
  
  The Browser Menu Service is gone.
  
  Use menu interfaces instead of id strings.
  
  


Changed:
  U   Zope3/trunk/src/zope/app/container/browser/adding.py
  U   Zope3/trunk/src/zope/app/container/browser/metaconfigure.py
  U   Zope3/trunk/src/zope/app/container/browser/tests/test_directive.py


-=-
Modified: Zope3/trunk/src/zope/app/container/browser/adding.py
===================================================================
--- Zope3/trunk/src/zope/app/container/browser/adding.py	2004-09-23 14:47:35 UTC (rev 27651)
+++ Zope3/trunk/src/zope/app/container/browser/adding.py	2004-09-23 14:47:37 UTC (rev 27652)
@@ -19,13 +19,15 @@
 $Id$
 """
 __docformat__ = 'restructuredtext'
+from warnings import warn
 
-from warnings import warn
 import zope.security.checker
+from zope.component.interfaces import IFactory
+from zope.event import notify
+from zope.i18n import translate
 from zope.interface import implements
 from zope.publisher.interfaces import IPublishTraverse
 from zope.security.proxy import removeSecurityProxy
-from zope.component.interfaces import IFactory
 
 from zope.app.exception.interfaces import UserError
 from zope.app.container.interfaces import IAdding, INameChooser
@@ -34,14 +36,13 @@
 
 from zope.app import zapi
 from zope.app.event.objectevent import ObjectCreatedEvent
+from zope.app.i18n import ZopeMessageIDFactory as _
+from zope.app.location import LocationProxy
 from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
-from zope.event import notify
 from zope.app.publisher.browser import BrowserView
+from zope.app.publisher.browser.menu import getMenu
+from zope.app.publisher.interfaces.browser import AddMenu
 
-from zope.app.i18n import ZopeMessageIDFactory as _
-from zope.i18n import translate
-from zope.app.location import LocationProxy
-
 class BasicAdding(BrowserView):
     implements(IAdding, IPublishTraverse)
 
@@ -177,12 +178,11 @@
         This is sorted by title.
         """
         container = self.context
-        menu_service = zapi.getService("BrowserMenu")
         result = []
-        for menu_id in (self.menu_id, 'zope.app.container.add'):
+        for menu_id in (self.menu_id, AddMenu):
             if not menu_id:
                 continue
-            for item in menu_service.getMenu(menu_id, self, self.request):
+            for item in getMenu(menu_id, self, self.request):
                 extra = item.get('extra')
                 if extra:
                     factory = extra.get('factory')

Modified: Zope3/trunk/src/zope/app/container/browser/metaconfigure.py
===================================================================
--- Zope3/trunk/src/zope/app/container/browser/metaconfigure.py	2004-09-23 14:47:35 UTC (rev 27651)
+++ Zope3/trunk/src/zope/app/container/browser/metaconfigure.py	2004-09-23 14:47:37 UTC (rev 27652)
@@ -60,16 +60,18 @@
             raise ValueError("A for interface must be specified.")
 
     if contents is not None:
+        from zope.app.menus import zmi_views
         page(_context, name='contents.html', permission=contents,
              for_=for_, class_=Contents, attribute='contents',
-             menu='zmi_views', title=_('Contents'))
+             menu=zmi_views, title=_('Contents'))
             
     if index is not None:
         page(_context, name='index.html', permission=index, for_=for_, 
              class_=Contents, attribute='index')
 
     if add is not None:
-        viewObj = view(_context, name='+', menu='zmi_actions',
+        from zope.app.menus import zmi_actions
+        viewObj = view(_context, name='+', menu=zmi_actions,
                        title=_('Add'), for_=for_, permission=add,
                        class_=Adding)
         viewObj.page(_context, name='index.html', attribute='index')

Modified: Zope3/trunk/src/zope/app/container/browser/tests/test_directive.py
===================================================================
--- Zope3/trunk/src/zope/app/container/browser/tests/test_directive.py	2004-09-23 14:47:35 UTC (rev 27651)
+++ Zope3/trunk/src/zope/app/container/browser/tests/test_directive.py	2004-09-23 14:47:37 UTC (rev 27652)
@@ -45,27 +45,40 @@
 
 def test_containerViews():
     """
+    >>> from zope.app.publisher.browser.menu import menus
+    >>> from zope.interface.interface import InterfaceClass
+    >>> zmi_views = InterfaceClass('zmi_views', __module__='zope.app.menus')
+    >>> menus.zmi_views = zmi_views
+    >>> zmi_actions = InterfaceClass('zmi_actions', __module__='zope.app.menus')
+    >>> menus.zmi_actions = zmi_actions
+
     >>> context = Context()
     >>> containerViews(context, for_=I, contents='zope.ManageContent',
     ...                add='zope.ManageContent', index='zope.View')
     >>> context
-    ((('browser:menuItem',
-       'zmi_views',
-       <InterfaceClass zope.app.container.browser.tests.test_directive.I>,
-       u'Contents'),
-      <bound method GlobalBrowserMenuService.menuItem of <zope.app.publisher.browser.globalbrowsermenuservice.GlobalBrowserMenuService object>>,
-      ('zmi_views',
-       <InterfaceClass zope.app.container.browser.tests.test_directive.I>,
-       '@@contents.html',
-       u'Contents',
-       '',
-       None,
-       'zope.ManageContent',
-       None)),
+    ((None,
+      <function handler>,
+      ('Adapters',
+       'subscribe',
+       (<InterfaceClass zope.app.container.browser.tests.test_directive.I>,
+        <InterfaceClass zope.publisher.interfaces.browser.IBrowserRequest>),
+       <InterfaceClass zope.app.menus.zmi_views>,
+       <function MenuItemFactory>)),
      (None,
       <function provideInterface>,
+      ('', <InterfaceClass zope.app.menus.zmi_views>)),
+     (None,
+      <function provideInterface>,
       ('',
        <InterfaceClass zope.app.container.browser.tests.test_directive.I>)),
+     (None,
+      <function provideInterface>,
+      ('',
+       <InterfaceClass zope.publisher.interfaces.browser.IBrowserRequest>)),
+     (None,
+      <function provideInterface>,
+      ('',
+       <InterfaceClass zope.app.container.browser.tests.test_directive.I>)),
      (('view',
        <InterfaceClass zope.app.container.browser.tests.test_directive.I>,
        'contents.html',
@@ -98,25 +111,31 @@
        'index.html',
        <class 'zope.app.publisher.browser.viewmeta.Contents'>,
        'info')),
-     (('browser:menuItem',
-       'zmi_actions',
-       <InterfaceClass zope.app.container.browser.tests.test_directive.I>,
-       u'Add'),
-      <bound method GlobalBrowserMenuService.menuItem of <zope.app.publisher.browser.globalbrowsermenuservice.GlobalBrowserMenuService object>>,
-      ('zmi_actions',
-       <InterfaceClass zope.app.container.browser.tests.test_directive.I>,
-       '@@+',
-       u'Add',
-       '',
-       None,
-       'zope.ManageContent',
-       None)),
      (None,
+      <function handler>,
+      ('Adapters',
+       'subscribe',
+       (<InterfaceClass zope.app.container.browser.tests.test_directive.I>,
+        <InterfaceClass zope.publisher.interfaces.browser.IBrowserRequest>),
+       <InterfaceClass zope.app.menus.zmi_actions>,
+       <function MenuItemFactory>)),
+     (None,
       <function provideInterface>,
+      ('', <InterfaceClass zope.app.menus.zmi_actions>)),
+     (None,
+      <function provideInterface>,
       ('',
        <InterfaceClass zope.app.container.browser.tests.test_directive.I>)),
      (None,
       <function provideInterface>,
+      ('',
+       <InterfaceClass zope.publisher.interfaces.browser.IBrowserRequest>)),
+     (None,
+      <function provideInterface>,
+      ('',
+       <InterfaceClass zope.app.container.browser.tests.test_directive.I>)),
+     (None,
+      <function provideInterface>,
       ('', <InterfaceClass zope.interface.Interface>)),
      (('view',
        <InterfaceClass zope.app.container.browser.tests.test_directive.I>,



More information about the Zope3-Checkins mailing list