summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@agendaless.com>2009-12-01 04:02:00 +0000
committerChris McDonough <chrism@agendaless.com>2009-12-01 04:02:00 +0000
commit4aa22c9561a29927da9ddc86ba488b91080380ee (patch)
tree91a0ba6c41d2535590be3ce004b6d5e45e1c77e6
parent6dd7806b6e2103292cd2a9a863d8a73412d78b5c (diff)
downloadpyramid-4aa22c9561a29927da9ddc86ba488b91080380ee.tar.gz
pyramid-4aa22c9561a29927da9ddc86ba488b91080380ee.tar.bz2
pyramid-4aa22c9561a29927da9ddc86ba488b91080380ee.zip
Organize into public and private interfaces.
-rw-r--r--repoze/bfg/interfaces.py117
1 files changed, 61 insertions, 56 deletions
diff --git a/repoze/bfg/interfaces.py b/repoze/bfg/interfaces.py
index 5b8ccf08b..479e3a751 100644
--- a/repoze/bfg/interfaces.py
+++ b/repoze/bfg/interfaces.py
@@ -1,9 +1,70 @@
from zope.interface import Attribute
from zope.interface import Interface
+# public API interfaces
+
+class IAfterTraversal(Interface):
+ """ An event type that is emitted after repoze.bfg completes
+ traversal but before it calls any view code."""
+ request = Attribute('The request object')
+
+class INewRequest(Interface):
+ """ An event type that is emitted whenever repoze.bfg begins to
+ process a new request """
+ request = Attribute('The request object')
+
+class INewResponse(Interface):
+ """ An event type that is emitted whenever any repoze.bfg view
+ returns a response."""
+ response = Attribute('The response object')
+
+class IWSGIApplicationCreatedEvent(Interface):
+ """ Event issued after the application has been created and
+ configured."""
+ app = Attribute(u"Published application")
+
+# internal interfaces
+
class IRequest(Interface):
""" Request type interface attached to all request objects """
+class IResponse(Interface):
+ status = Attribute('WSGI status code of response')
+ headerlist = Attribute('List of response headers')
+ app_iter = Attribute('Iterable representing the response body')
+
+class IAuthenticationPolicy(Interface):
+ """ An object representing a BFG authentication policy. """
+ def authenticated_userid(request):
+ """ Return the authenticated userid or ``None`` if no
+ authenticated userid can be found. """
+
+ def effective_principals(request):
+ """ Return a sequence representing the effective principals
+ including the userid and any groups belonged to by the current
+ user, including 'system' groups such as Everyone and
+ Authenticated. """
+
+ def remember(request, principal, **kw):
+ """ Return a set of headers suitable for 'remembering' the
+ principal named ``principal`` when set in a response. An
+ individual authentication policy and its consumers can decide
+ on the composition and meaning of **kw. """
+
+ def forget(request):
+ """ Return a set of headers suitable for 'forgetting' the
+ current user on subsequent requests. """
+
+class IAuthorizationPolicy(Interface):
+ """ An object representing a BFG authorization policy. """
+ def permits(context, principals, permission):
+ """ Return True if any of the principals is allowed the
+ permission in the current context, else return False """
+
+ def principals_allowed_by_permission(context, permission):
+ """ Return a set of principal identifiers allowed by the permission """
+
+
class IRouteRequest(Interface):
""" *internal only* interface used as in a utility lookup to find
route-specific interfaces. Not an API."""
@@ -16,11 +77,6 @@ class IResponseFactory(Interface):
should accept all the arguments that the webob.Response class
accepts)"""
-class IResponse(Interface):
- status = Attribute('WSGI status code of response')
- headerlist = Attribute('List of response headers')
- app_iter = Attribute('Iterable representing the response body')
-
class IView(Interface):
def __call__(context, request):
""" Must return an object that implements IResponse. May
@@ -114,30 +170,10 @@ class IRouter(Interface):
registry = Attribute(
"""Component architecture registry local to this application.""")
-class IAfterTraversal(Interface):
- """ An event type that is emitted after repoze.bfg completes
- traversal but before it calls any view code."""
- request = Attribute('The request object')
-
-class INewRequest(Interface):
- """ An event type that is emitted whenever repoze.bfg begins to
- process a new request """
- request = Attribute('The request object')
-
-class INewResponse(Interface):
- """ An event type that is emitted whenever any repoze.bfg view
- returns a response."""
- response = Attribute('The response object')
-
class ISettings(Interface):
""" Runtime settings utility for repoze.bfg; represents the
deployment settings for the application"""
-class IWSGIApplicationCreatedEvent(Interface):
- """ Event issued after the application has been created and
- configured."""
- app = Attribute(u"Published application")
-
# this interface, even if it becomes unused within BFG, is imported by
# other packages (such as repoze.bfg.traversalwrapper)
class ILocation(Interface):
@@ -186,37 +222,6 @@ class IContextURL(Interface):
def __call__():
""" Return a URL that points to the context """
-class IAuthenticationPolicy(Interface):
- """ An object representing a BFG authentication policy. """
- def authenticated_userid(request):
- """ Return the authenticated userid or ``None`` if no
- authenticated userid can be found. """
-
- def effective_principals(request):
- """ Return a sequence representing the effective principals
- including the userid and any groups belonged to by the current
- user, including 'system' groups such as Everyone and
- Authenticated. """
-
- def remember(request, principal, **kw):
- """ Return a set of headers suitable for 'remembering' the
- principal named ``principal`` when set in a response. An
- individual authentication policy and its consumers can decide
- on the composition and meaning of **kw. """
-
- def forget(request):
- """ Return a set of headers suitable for 'forgetting' the
- current user on subsequent requests. """
-
-class IAuthorizationPolicy(Interface):
- """ An object representing a BFG authorization policy. """
- def permits(context, principals, permission):
- """ Return True if any of the principals is allowed the
- permission in the current context, else return False """
-
- def principals_allowed_by_permission(context, permission):
- """ Return a set of principal identifiers allowed by the permission """
-
class IPackageOverrides(Interface):
""" Utility for pkg_resources overrides """