summaryrefslogtreecommitdiff
path: root/repoze/bfg/security.py
diff options
context:
space:
mode:
authorChris McDonough <chrism@agendaless.com>2008-09-01 01:52:14 +0000
committerChris McDonough <chrism@agendaless.com>2008-09-01 01:52:14 +0000
commit7e2c6cbb452aa986891b2a99653a147bfb053e19 (patch)
treeb4c2bbfee120b1796b2bbe08673f9ab11a4e220c /repoze/bfg/security.py
parent5d906eae19891ba8074a233d167cb371fe89deb0 (diff)
downloadpyramid-7e2c6cbb452aa986891b2a99653a147bfb053e19.tar.gz
pyramid-7e2c6cbb452aa986891b2a99653a147bfb053e19.tar.bz2
pyramid-7e2c6cbb452aa986891b2a99653a147bfb053e19.zip
- New API module: ``repoze.bfg.view``. This module contains the functions
named ``render_view_to_response``, ``render_view_to_iterable`` and ``is_response``, which are documented in the API docs. These features aid programmatic (non-request-driven) view execution.
Diffstat (limited to 'repoze/bfg/security.py')
-rw-r--r--repoze/bfg/security.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/repoze/bfg/security.py b/repoze/bfg/security.py
index 6535f2608..226cf8664 100644
--- a/repoze/bfg/security.py
+++ b/repoze/bfg/security.py
@@ -203,7 +203,7 @@ class PermitsResult:
self.context_repr = repr(context)
def __str__(self):
- msg = '%s: %r via ace %r in acl %s or principals %r in context %s'
+ msg = '%s: %r via ace %r in acl %r or principals %r in context %s'
msg = msg % (self.__class__.__name__,
self.permission, self.ace, self.acl, self.principals,
self.context_repr)
@@ -219,8 +219,7 @@ class Denied(PermitsResult):
return False
def __eq__(self, other):
- if bool(other) is False:
- return True
+ return bool(other) is False
class Allowed(PermitsResult):
""" An instance of ``Allowed`` is returned by an ACL allow. It
@@ -232,8 +231,7 @@ class Allowed(PermitsResult):
return True
def __eq__(self, other):
- if bool(other) is True:
- return True
+ return bool(other) is True
def flatten(x):
"""flatten(sequence) -> list
@@ -281,4 +279,12 @@ class ViewPermissionFactory(object):
def __call__(self, context, request):
return ViewPermission(context, request, self.permission_name)
+class Unauthorized(Exception):
+ def __init__(self, message='Unauthorized'):
+ self.message = message
+
+ def __str__(self):
+ return str(self.message)
+
+