[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/ZMI/Browser - ManagementViewSelector.py:1.1 configure.zcml:1.1
Jim Fulton
jim@zope.com
Tue, 1 Oct 2002 08:58:03 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/ZMI/Browser
In directory cvs.zope.org:/tmp/cvs-serv19547/ZMI/Browser
Added Files:
ManagementViewSelector.py configure.zcml
Log Message:
Added a new view, 'SelectedManagementView', that redirects to the first
view that a user can access. Changed between-object navigation urls,
like those in breadcrumbs and the contents management view, to use
this view. This corresponds to Zope 2's 'manage_workspace' method.
Changes the name of the folder contents management view to
'contents.html'. Added a new 'index.html' view as the default view for
folders. If the folder contains an object named 'index.html', then the
view redirects to that object. Otherwise, the view displays a folder
listing with linds to folder items.
Changed the view order for a number of content types so that
management views come before the default view. This means you can now
traverse to a file or page template from a contents listing and get an
editing view.
=== Added File Zope3/lib/python/Zope/App/ZMI/Browser/ManagementViewSelector.py ===
##############################################################################
#
# 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: ManagementViewSelector.py,v 1.1 2002/10/01 12:58:03 jim Exp $
"""
__metaclass__ = type
from Zope.ComponentArchitecture import getService
from Zope.Publisher.Browser.BrowserView import BrowserView
from Zope.Publisher.Browser.IBrowserPublisher import IBrowserPublisher
from Zope.Exceptions import Unauthorized
class ManagementViewSelector(BrowserView):
"""View that selects the first available management view
"""
__implements__ = BrowserView.__implements__, IBrowserPublisher
def browserDefault(self, request):
return self, ()
def __call__(self):
context = self.context
request = self.request
browser_menu_service = getService(context, 'BrowserMenu')
item = browser_menu_service.getFirstMenuItem(
'zmi_views', context, request)
if item:
request.response.redirect(item['action'])
return ''
raise Unauthorized()
__doc__ = ManagementViewSelector.__doc__ + __doc__
=== Added File Zope3/lib/python/Zope/App/ZMI/Browser/configure.zcml ===
<zopeConfigure
xmlns='http://namespaces.zope.org/zope'
xmlns:browser='http://namespaces.zope.org/browser'
>
<browser:view name="SelectedManagementView.html"
permission="Zope.View"
factory=".ManagementViewSelector." />
<include package=".ZopeTop" />
</zopeConfigure>