[Zope3-checkins] CVS: Zope3/src/zope/app/browser/security/grants - principalpermissionview.py:1.1.2.2
Fred L. Drake, Jr.
fred@zope.com
Tue, 24 Dec 2002 02:22:21 -0500
Update of /cvs-repository/Zope3/src/zope/app/browser/security/grants
In directory cvs.zope.org:/tmp/cvs-serv22270
Modified Files:
Tag: NameGeddon-branch
principalpermissionview.py
Log Message:
- fix & clean up imports
- remove unused import
- general cleanup, normalize whitespace
=== Zope3/src/zope/app/browser/security/grants/principalpermissionview.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/app/browser/security/grants/principalpermissionview.py:1.1.2.1 Mon Dec 23 14:31:10 2002
+++ Zope3/src/zope/app/browser/security/grants/principalpermissionview.py Tue Dec 24 02:22:20 2002
@@ -2,14 +2,14 @@
#
# 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.
-#
+#
##############################################################################
"""
@@ -17,14 +17,13 @@
"""
import time
-from Zope.App.PageTemplate import ViewPageTemplateFile
-from zope.publisher.browser import BrowserView
-from zope.component.contextdependent import ContextDependent
-from zope.component import getService, getAdapter
+from zope.app.interfaces.security import IPrincipalPermissionManager
from zope.app.interfaces.security import IPrincipalPermissionMap
-from zope.app.interfaces.security \
- import IPrincipalPermissionManager
+from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
from zope.app.security.settings import Allow, Deny, Unset
+from zope.component import getService, getAdapter
+from zope.publisher.browser import BrowserView
+
class PrincipalPermissionView(BrowserView):
@@ -91,17 +90,17 @@
result.append(perm)
return result
-
+
def getPermissionsForPrincipal(self, principal_id, setting_name):
"""Return a list of permissions with the given setting_name
string for the principal.
-
+
Return empty list if there are no permissions.
"""
-
+
ppmap = getAdapter(self.context, IPrincipalPermissionMap)
principal = self.get_principal(principal_id)
-
+
permission_settings = ppmap.getPermissionsForPrincipal(principal)
setting_map = {'Deny': Deny, 'Allow':Allow}
asked_setting = setting_map[setting_name]
@@ -110,5 +109,5 @@
for permission, setting in permission_settings:
if asked_setting == setting:
result.append(permission)
-
+
return result