• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

zopefoundation / zope.app.publisher / 16399746590

25 Jun 2025 07:15AM UTC coverage: 98.992%. Remained the same
16399746590

push

github

web-flow
Update Python version support. (#20)

* Drop support for Python 3.8.

39 of 44 branches covered (88.64%)

Branch coverage included in aggregate %.

452 of 452 relevant lines covered (100.0%)

1.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.24
/src/zope/app/publisher/browser/managementviewselector.py
1
##############################################################################
2
#
3
# Copyright (c) 2002 Zope Foundation and Contributors.
4
# All Rights Reserved.
5
#
6
# This software is subject to the provisions of the Zope Public License,
7
# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
8
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
9
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
10
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
11
# FOR A PARTICULAR PURPOSE.
12
#
13
##############################################################################
14
"""Selecting first available and allowed management view
15

16
"""
17

18
from zope.browsermenu.menu import getFirstMenuItem
1✔
19
from zope.interface import implementer
1✔
20
from zope.publisher.browser import BrowserView
1✔
21
from zope.publisher.interfaces.browser import IBrowserPublisher
1✔
22

23

24
@implementer(IBrowserPublisher)
1✔
25
class ManagementViewSelector(BrowserView):
1✔
26
    """View that selects the first available management view.
27

28
    Support 'zmi_views' actions like: 'javascript:alert("hello")',
29
    '../view_on_parent.html' or '++rollover++'.
30
    """
31

32
    def browserDefault(self, request):
1✔
33
        return self, ()
1✔
34

35
    def __call__(self):
1✔
36
        item = getFirstMenuItem('zmi_views', self.context, self.request)
1✔
37

38
        if item:
1✔
39
            redirect_url = item['action']
1✔
40
            if not (redirect_url.startswith('../') or
1!
41
                    redirect_url.lower().startswith('javascript:') or
42
                    redirect_url.lower().startswith('++')):
43
                self.request.response.redirect(redirect_url)
1✔
44
                return ''
1✔
45

46
        self.request.response.redirect('.')  # Redirect to content/
1✔
47
        return ''
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc