Zope Subversion Repository

  Zope

Zope: Zope3/trunk/src/zope/security/simplepolicies.py

File: [Zope] / Zope3 / trunk / src / zope / security / simplepolicies.py (download) (as text)
Revision: 9625, Fri Apr 11 22:15:48 2003 UTC (10 years, 2 months ago) by gotcha
File size: 1489 byte(s)
- added usage argument to ZCML menu directive
  The menu usage is used by the configuration to initialize
  the page view usage in case a page is registered as a
  menu item included in a menu declared with a usage argument.

- added corresponding tests

- various ZCML refactorings to improve usage initialization

- added tests for menu and usage on page directive
##############################################################################
#
# 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.
#
##############################################################################
""" Simple ISecurityPolicy implementations."""

from zope.security.interfaces import ISecurityPolicy
from zope.exceptions import Unauthorized
from zope.security.management import system_user
import zope.security.checker

class ParanoidSecurityPolicy:
    """
        Deny all access.
    """
    __implements__ = ISecurityPolicy

    def checkPermission(self, permission, object, context):
        if permission is zope.security.checker.CheckerPublic:
            return 1
        if (context.user is system_user   # no user
            and not context.stack  # no untrusted code
            ):
            return 1 # Nobody not to trust!

        return 0

class PermissiveSecurityPolicy:
    """
        Allow all access
    """
    __implements__ = ISecurityPolicy

    def checkPermission(self, permission, object, context):
        return 1

webmaster@zope.org

Powered by ViewCVS 1.0-dev
(Powered by Apache)

ViewCVS and CVS Help