[Zope3-checkins] SVN: Zope3/trunk/ Disentangle the zope.app.menu package from the Zope X3 components.

Fred L. Drake, Jr. fred at zope.com
Wed May 26 15:05:58 EDT 2004


Log message for revision 25020:
Disentangle the zope.app.menu package from the Zope X3 components.
This involved moving a couple of basic views into the
zope.app.publisher.browser package; a better place may need to be found
later.



-=-
Added: Zope3/trunk/package-includes/zope.app.menu-configure.zcml
===================================================================
--- Zope3/trunk/package-includes/zope.app.menu-configure.zcml	2004-05-26 18:36:45 UTC (rev 25019)
+++ Zope3/trunk/package-includes/zope.app.menu-configure.zcml	2004-05-26 19:05:58 UTC (rev 25020)
@@ -0,0 +1 @@
+<include package="zope.app.menu" />


Property changes on: Zope3/trunk/package-includes/zope.app.menu-configure.zcml
___________________________________________________________________
Name: svn:mime-type
   + text/xml
Name: svn:eol-style
   + native

Modified: Zope3/trunk/src/zope/app/PACKAGE.cfg
===================================================================
--- Zope3/trunk/src/zope/app/PACKAGE.cfg	2004-05-26 18:36:45 UTC (rev 25019)
+++ Zope3/trunk/src/zope/app/PACKAGE.cfg	2004-05-26 19:05:58 UTC (rev 25020)
@@ -91,8 +91,7 @@
 zapi
 
 # These will likely be moved out before long, but are still needed by
-# zope.app.process.bootstrap:
+# zope.app.appsetup.bootstrap:
 hub
-menu
 
 </collection>

Modified: Zope3/trunk/src/zope/app/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/configure.zcml	2004-05-26 18:36:45 UTC (rev 25019)
+++ Zope3/trunk/src/zope/app/configure.zcml	2004-05-26 19:05:58 UTC (rev 25020)
@@ -49,7 +49,6 @@
   <!-- Services -->
   <include package="zope.app.errorservice" />  
   <include package="zope.app.hub" />  
-  <include package="zope.app.menu" />  
   <include package="zope.app.pluggableauth" />  
   <include package="zope.app.site" />  
   <include package="zope.app.adapter" />

Added: Zope3/trunk/src/zope/app/menu/SETUP.cfg
===================================================================
--- Zope3/trunk/src/zope/app/menu/SETUP.cfg	2004-05-26 18:36:45 UTC (rev 25019)
+++ Zope3/trunk/src/zope/app/menu/SETUP.cfg	2004-05-26 19:05:58 UTC (rev 25020)
@@ -0,0 +1,5 @@
+# Tell zpkg about the ZCML slugs.
+
+<data-files etc/package-includes>
+  zope.app.menu-*.zcml
+</data-files>

Modified: Zope3/trunk/src/zope/app/menu/browser/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/menu/browser/__init__.py	2004-05-26 18:36:45 UTC (rev 25019)
+++ Zope3/trunk/src/zope/app/menu/browser/__init__.py	2004-05-26 19:05:58 UTC (rev 25020)
@@ -16,26 +16,14 @@
 $Id$
 """
 from zope.interface import implements
-from zope.app.publisher.browser import BrowserView
 from zope.app import zapi
 from zope.app.container.browser.contents import Contents
 from zope.app.component.localservice import queryNextService
 from zope.app.dublincore.interfaces import IZopeDublinCore
 from zope.app.menu.interfaces import ILocalBrowserMenu
 from zope.app.servicenames import Utilities, BrowserMenu
-from interfaces import IMenuAccessView
 
-class MenuAccessView(BrowserView):
 
-    implements(IMenuAccessView)
-
-    def __getitem__(self, menu_id):
-        browser_menu_service = zapi.getService(self.context, 'BrowserMenu')
-        return browser_menu_service.getMenu(menu_id,
-                                            self.context,
-                                            self.request)
-
-
 class MenuContents(Contents):
 
     def _extractContentInfo(self, item):

Modified: Zope3/trunk/src/zope/app/menu/browser/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/menu/browser/configure.zcml	2004-05-26 18:36:45 UTC (rev 25019)
+++ Zope3/trunk/src/zope/app/menu/browser/configure.zcml	2004-05-26 19:05:58 UTC (rev 25020)
@@ -116,30 +116,4 @@
       name="edit.html" />
 
 
-  <!-- Management view selector -->
-  <!-- Get first accessable item from zmi_views menu -->
-  <page
-      for="*"
-      name="SelectedManagementView.html"
-      permission="zope.Public"
-      class=".managementviewselector.ManagementViewSelector"
-      allowed_interface="zope.publisher.interfaces.browser.IBrowserPublisher" />
-
-  <!-- Make manage an alias for same -->
-  <page
-      for="*"
-      name="manage"
-      permission="zope.ManageContent"
-      class=".managementviewselector.ManagementViewSelector"
-      allowed_interface="zope.publisher.interfaces.browser.IBrowserPublisher" />
-
-  <!-- Menu access -->
-  <page
-      for="*"
-      name="view_get_menu"
-      permission="zope.Public"
-      class=".MenuAccessView"
-      allowed_interface=".interfaces.IMenuAccessView"
-      />
-
 </zope:configure>

Deleted: Zope3/trunk/src/zope/app/menu/browser/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/menu/browser/interfaces.py	2004-05-26 18:36:45 UTC (rev 25019)
+++ Zope3/trunk/src/zope/app/menu/browser/interfaces.py	2004-05-26 19:05:58 UTC (rev 25020)
@@ -1,27 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.0 (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.
-#
-##############################################################################
-"""
-$Id$
-"""
-from zope.interface import Interface
-
-class IMenuAccessView(Interface):
-    """View that provides access to menus"""
-
-    def __getitem__(menu_id):
-        """Get menu information
-
-        Return a sequence of dictionaries with labels and
-        actions, where actions are relative URLs.
-        """

Deleted: Zope3/trunk/src/zope/app/menu/browser/managementviewselector.py
===================================================================
--- Zope3/trunk/src/zope/app/menu/browser/managementviewselector.py	2004-05-26 18:36:45 UTC (rev 25019)
+++ Zope3/trunk/src/zope/app/menu/browser/managementviewselector.py	2004-05-26 19:05:58 UTC (rev 25020)
@@ -1,41 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.0 (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.
-#
-##############################################################################
-"""Selecting first available and allowed management view
-
-$Id$
-"""
-from zope.interface import implements
-from zope.app.publisher.browser import BrowserView
-from zope.publisher.interfaces.browser import IBrowserPublisher
-from zope.app import zapi
-from zope.app.servicenames import BrowserMenu
-
-class ManagementViewSelector(BrowserView):
-    """View that selects the first available management view."""
-    implements(IBrowserPublisher)
-
-    def browserDefault(self, request):
-        return self, ()
-
-    def __call__(self):
-        browser_menu_service = zapi.getService(self.context, BrowserMenu)
-        item = browser_menu_service.getFirstMenuItem(
-            'zmi_views', self.context, self.request)
-
-        if item:
-            self.request.response.redirect(item['action'])
-            return u''
-
-        self.request.response.redirect('.') # Redirect to content/
-        return u''

Deleted: Zope3/trunk/src/zope/app/menu/browser/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/menu/browser/tests.py	2004-05-26 18:36:45 UTC (rev 25019)
+++ Zope3/trunk/src/zope/app/menu/browser/tests.py	2004-05-26 19:05:58 UTC (rev 25020)
@@ -1,112 +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.0 (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.
-#
-##############################################################################
-"""Browser Menu Browser Tests
-
-$Id$
-"""
-import unittest
-
-from zope.interface import Interface, implements
-from zope.component import getServices, getGlobalServices
-
-from zope.security.management import newInteraction
-from zope.security.checker import defineChecker, NamesChecker, CheckerPublic
-from zope.security.proxy import ProxyFactory
-
-from zope.publisher.browser import TestRequest
-from zope.publisher.interfaces.browser import IBrowserPublisher
-from zope.app.publisher.interfaces.browser import IBrowserView
-
-from zope.app.tests import ztapi
-from zope.app.site.tests.placefulsetup import PlacefulSetup
-
-from zope.app.publisher.interfaces.browser import IBrowserMenuService
-from zope.app.menu.browser import MenuAccessView
-from zope.app.publication.traversers import TestTraverser
-from zope.app.site.interfaces import ISimpleService
-
-def d(title, action):
-    return {'action': action, 'title': title, 'description': ''}
-
-class Service:
-    implements(IBrowserMenuService, ISimpleService)
-
-    def getMenu(self, name, ob, req):
-        return [d('l1', 'a1'),
-                d('l2', 'a2/a3'),
-                d('l3', '@@a3'),]
-
-class I(Interface): pass
-class C:
-    implements(I)
-
-    def __call__(self):
-        pass
-
-ob = C()
-ob.a1 = C()
-ob.a2 = C()
-ob.a2.a3 = C()
-ob.abad = C()
-ob.abad.bad = 1
-
-class V:
-    implements(IBrowserView)
-
-    def __init__(self, context, request):
-        self.context = context
-        self.request = request
-
-    def __call__(self):
-        pass
-
-class ParticipationStub:
-
-    def __init__(self, principal):
-        self.principal = principal
-        self.interaction = None
-
-
-class Test(PlacefulSetup, unittest.TestCase):
-
-    def setUp(self):
-        PlacefulSetup.setUp(self)
-        defineService = getGlobalServices().defineService
-        provideService = getGlobalServices().provideService
-
-
-        defineService('BrowserMenu', IBrowserMenuService)
-        provideService('BrowserMenu', Service())
-        ztapi.browserView(I, 'a3', V)
-        ztapi.browserViewProviding(None, IBrowserPublisher, TestTraverser)
-        defineChecker(C, NamesChecker(['a1', 'a2', 'a3', '__call__'],
-                                      CheckerPublic,
-                                      abad='waaa'))
-
-    def test(self):
-        newInteraction(ParticipationStub('who'))
-        v = MenuAccessView(ProxyFactory(ob), TestRequest())
-        self.assertEqual(v['zmi_views'],
-                         [{'description': '', 'title':'l1', 'action':'a1'},
-                          {'description': '', 'title':'l2', 'action':'a2/a3'},
-                          {'description': '', 'title':'l3', 'action':'@@a3'}
-                          ])
-
-
-def test_suite():
-    loader = unittest.TestLoader()
-    return loader.loadTestsFromTestCase(Test)
-
-if __name__=='__main__':
-    unittest.TextTestRunner().run(test_suite())

Added: Zope3/trunk/src/zope/app/menu/zope.app.menu-configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/menu/zope.app.menu-configure.zcml	2004-05-26 18:36:45 UTC (rev 25019)
+++ Zope3/trunk/src/zope/app/menu/zope.app.menu-configure.zcml	2004-05-26 19:05:58 UTC (rev 25020)
@@ -0,0 +1 @@
+<include package="zope.app.menu" />


Property changes on: Zope3/trunk/src/zope/app/menu/zope.app.menu-configure.zcml
___________________________________________________________________
Name: svn:mime-type
   + text/xml
Name: svn:eol-style
   + native

Modified: Zope3/trunk/src/zope/app/publisher/browser/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/configure.zcml	2004-05-26 18:36:45 UTC (rev 25019)
+++ Zope3/trunk/src/zope/app/publisher/browser/configure.zcml	2004-05-26 19:05:58 UTC (rev 25020)
@@ -65,4 +65,32 @@
     allowed_interface="zope.publisher.interfaces.browser.IBrowserPublisher"
     />
 
+<!-- Management view selector -->
+<!-- Get first accessable item from zmi_views menu -->
+<browser:page
+    for="*"
+    name="SelectedManagementView.html"
+    permission="zope.Public"
+    class=".managementviewselector.ManagementViewSelector"
+    allowed_interface="zope.publisher.interfaces.browser.IBrowserPublisher"
+    />
+
+<!-- Make manage an alias for same -->
+<browser:page
+    for="*"
+    name="manage"
+    permission="zope.ManageContent"
+    class=".managementviewselector.ManagementViewSelector"
+    allowed_interface="zope.publisher.interfaces.browser.IBrowserPublisher"
+    />
+
+<!-- Menu access -->
+<browser:page
+    for="*"
+    name="view_get_menu"
+    permission="zope.Public"
+    class=".globalbrowsermenuservice.MenuAccessView"
+    allowed_interface="zope.app.publisher.interfaces.browser.IMenuAccessView"
+    />
+
 </configure>

Modified: Zope3/trunk/src/zope/app/publisher/browser/globalbrowsermenuservice.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/globalbrowsermenuservice.py	2004-05-26 18:36:45 UTC (rev 25019)
+++ Zope3/trunk/src/zope/app/publisher/browser/globalbrowsermenuservice.py	2004-05-26 19:05:58 UTC (rev 25020)
@@ -29,12 +29,27 @@
 from zope.app.publisher.interfaces.browser import IBrowserMenuService
 from zope.app.publisher.interfaces.browser import IGlobalBrowserMenuService
 from zope.app.publisher.interfaces.browser import IBrowserMenu
+from zope.app.publisher.interfaces.browser import IMenuAccessView
+from zope.app.publisher.browser import BrowserView
 from zope.app.pagetemplate.engine import Engine
 from zope.app.publication.browser import PublicationTraverser
 from zope.security.proxy import ProxyFactory
 from zope.app import zapi
 from zope.app.component.interface import provideInterface
+from zope.app.servicenames import BrowserMenu
 
+
+class MenuAccessView(BrowserView):
+
+    implements(IMenuAccessView)
+
+    def __getitem__(self, menu_id):
+        browser_menu_service = zapi.getService(self.context, BrowserMenu)
+        return browser_menu_service.getMenu(menu_id,
+                                            self.context,
+                                            self.request)
+
+
 class Menu:
     """Browser menu"""
 

Copied: Zope3/trunk/src/zope/app/publisher/browser/managementviewselector.py (from rev 25011, Zope3/trunk/src/zope/app/menu/browser/managementviewselector.py)

Copied: Zope3/trunk/src/zope/app/publisher/browser/tests/test_menuaccessview.py (from rev 25011, Zope3/trunk/src/zope/app/menu/browser/tests.py)
===================================================================
--- Zope3/trunk/src/zope/app/menu/browser/tests.py	2004-05-26 15:09:27 UTC (rev 25011)
+++ Zope3/trunk/src/zope/app/publisher/browser/tests/test_menuaccessview.py	2004-05-26 19:05:58 UTC (rev 25020)
@@ -0,0 +1,112 @@
+##############################################################################
+#
+# 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.0 (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.
+#
+##############################################################################
+"""Browser Menu Browser Tests
+
+$Id$
+"""
+import unittest
+
+from zope.interface import Interface, implements
+from zope.component import getServices, getGlobalServices
+
+from zope.security.management import newInteraction
+from zope.security.checker import defineChecker, NamesChecker, CheckerPublic
+from zope.security.proxy import ProxyFactory
+
+from zope.publisher.browser import TestRequest
+from zope.publisher.interfaces.browser import IBrowserPublisher
+from zope.app.publisher.interfaces.browser import IBrowserView
+
+from zope.app.tests import ztapi
+from zope.app.servicenames import BrowserMenu
+from zope.app.site.tests.placefulsetup import PlacefulSetup
+
+from zope.app.publisher.interfaces.browser import IBrowserMenuService
+from zope.app.publisher.browser.globalbrowsermenuservice import MenuAccessView
+from zope.app.publication.traversers import TestTraverser
+from zope.app.site.interfaces import ISimpleService
+
+def d(title, action):
+    return {'action': action, 'title': title, 'description': ''}
+
+class Service:
+    implements(IBrowserMenuService, ISimpleService)
+
+    def getMenu(self, name, ob, req):
+        return [d('l1', 'a1'),
+                d('l2', 'a2/a3'),
+                d('l3', '@@a3'),]
+
+class I(Interface): pass
+class C:
+    implements(I)
+
+    def __call__(self):
+        pass
+
+ob = C()
+ob.a1 = C()
+ob.a2 = C()
+ob.a2.a3 = C()
+ob.abad = C()
+ob.abad.bad = 1
+
+class V:
+    implements(IBrowserView)
+
+    def __init__(self, context, request):
+        self.context = context
+        self.request = request
+
+    def __call__(self):
+        pass
+
+class ParticipationStub:
+
+    def __init__(self, principal):
+        self.principal = principal
+        self.interaction = None
+
+
+class Test(PlacefulSetup, unittest.TestCase):
+
+    def setUp(self):
+        PlacefulSetup.setUp(self)
+        defineService = getGlobalServices().defineService
+        provideService = getGlobalServices().provideService
+
+        defineService(BrowserMenu, IBrowserMenuService)
+        provideService(BrowserMenu, Service())
+        ztapi.browserView(I, 'a3', V)
+        ztapi.browserViewProviding(None, IBrowserPublisher, TestTraverser)
+        defineChecker(C, NamesChecker(['a1', 'a2', 'a3', '__call__'],
+                                      CheckerPublic,
+                                      abad='waaa'))
+
+    def test(self):
+        newInteraction(ParticipationStub('who'))
+        v = MenuAccessView(ProxyFactory(ob), TestRequest())
+        self.assertEqual(v['zmi_views'],
+                         [{'description': '', 'title':'l1', 'action':'a1'},
+                          {'description': '', 'title':'l2', 'action':'a2/a3'},
+                          {'description': '', 'title':'l3', 'action':'@@a3'}
+                          ])
+
+
+def test_suite():
+    loader = unittest.TestLoader()
+    return loader.loadTestsFromTestCase(Test)
+
+if __name__=='__main__':
+    unittest.TextTestRunner().run(test_suite())

Modified: Zope3/trunk/src/zope/app/publisher/interfaces/browser.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/interfaces/browser.py	2004-05-26 18:36:45 UTC (rev 25019)
+++ Zope3/trunk/src/zope/app/publisher/interfaces/browser.py	2004-05-26 19:05:58 UTC (rev 25020)
@@ -158,3 +158,13 @@
                  description='', filter_string=None, permission=None):
         """Add a menu item to a specific menu."""
 
+
+class IMenuAccessView(Interface):
+    """View that provides access to menus"""
+
+    def __getitem__(menu_id):
+        """Get menu information
+
+        Return a sequence of dictionaries with labels and
+        actions, where actions are relative URLs.
+        """

Modified: Zope3/trunk/src/zope/app/site/browser/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/site/browser/configure.zcml	2004-05-26 18:36:45 UTC (rev 25019)
+++ Zope3/trunk/src/zope/app/site/browser/configure.zcml	2004-05-26 19:05:58 UTC (rev 25020)
@@ -43,7 +43,7 @@
      for="zope.app.site.interfaces.ILocalService"
      name="index.html"
      permission="zope.ManageServices"
-     class="zope.app.menu.browser.managementviewselector.ManagementViewSelector"
+     class="zope.app.publisher.browser.managementviewselector.ManagementViewSelector"
      allowed_interface="zope.publisher.interfaces.browser.IBrowserPublisher"
      />
 




More information about the Zope3-Checkins mailing list