[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Security - publicClass.py:1.1.2.1
Ken Manheimer
klm@zope.com
Fri, 30 Nov 2001 17:05:30 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/Security
In directory cvs.zope.org:/tmp/cvs-serv25008
Added Files:
Tag: Zope-3x-branch
publicClass.py
Log Message:
Initial implementation, derived from (modified) protectClass.
=== Added File Zope3/lib/python/Zope/App/Security/publicClass.py ===
# publicClass.py
#
# Copyright (c) 2001 Zope Coporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 1.1 (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.
"""Create the public (unprotected) declarations object.
Invalid public declarations raise ProtectionDeclarationException
instances."""
from Zope.Configuration.name import resolve
from Interface.Method import Method
from PermissionRegistry import PublicPermission
from protectClass import protectClass
class PublicDeclarationException(Exception):
"""Security-protection-specific exception."""
pass
class publicClass(protectClass):
def __init__(self, name, permission=None, interface=None,
method=None, methods=None):
self._getPermission(permission) # Prohibit explicit permission!
protectClass.__init__(self, name, permission=PublicPermission,
interface=interface, method=method,
methods=methods)
def _getPermission(self, permission=None):
if permission not in [None, PublicPermission]:
raise PublicDeclarationException(
"It's invalid to specify a permission in public declarations.")
return permission
def __call__(self):
protectClass.__call__(self)