[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/Security - PermissionField.py:1.1 configure.zcml:1.5
Steve Alexander
steve@cat-box.net
Sat, 21 Dec 2002 14:57:06 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/Security
In directory cvs.zope.org:/tmp/cvs-serv9329/lib/python/Zope/App/Security
Modified Files:
configure.zcml
Added Files:
PermissionField.py
Log Message:
Added a PermissionField and its associated widgets.
This works like an InterfaceWidget. Use it to select a permission from
those that are available.
=== Added File Zope3/lib/python/Zope/App/Security/PermissionField.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.
#
##############################################################################
"""These are the interfaces for the common fields.
$Id: PermissionField.py,v 1.1 2002/12/21 19:56:36 stevea Exp $
"""
from Zope.Schema.IField import IValueSet
from Zope.Schema import ValueSet
from Zope.Schema.Exceptions import ValidationError
from Zope.ComponentArchitecture import queryService
class IPermissionField(IValueSet):
u"""Fields with Permissions as values
"""
class PermissionField(ValueSet):
__doc__ = IPermissionField.__doc__
__implements__ = IPermissionField
def _validate(self, value):
super(PermissionField, self)._validate(value)
# XXX I'd like to use getService here, but _validate is called
# before the zcml actions are executed, so this gets
# called before even the Permissions service is set up.
service = queryService(self.context, 'Permissions', None)
if service is None:
# XXX Permissions service not found, so we can't validate.
# Perhaps log some message here.
pass
else:
if service.getPermission(value.getId()) is None:
raise ValidationError("Unknown permission", value)
=== Zope3/lib/python/Zope/App/Security/configure.zcml 1.4 => 1.5 ===
--- Zope3/lib/python/Zope/App/Security/configure.zcml:1.4 Tue Nov 19 18:25:14 2002
+++ Zope3/lib/python/Zope/App/Security/configure.zcml Sat Dec 21 14:56:36 2002
@@ -55,6 +55,8 @@
<adapter factory="Zope.App.Security.BasicVFSAuthAdapter."
provides="Zope.App.Security.ILoginPassword."
for="Zope.Publisher.VFS.IVFSCredentials." />
+
+ <include package=".Browser" />
</zopeConfigure>