From c6895b23b63365a983cf564fc67446913ef2bebd Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Thu, 24 Dec 2009 01:26:37 +0000 Subject: Roles. --- repoze/bfg/wsgi.py | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) (limited to 'repoze/bfg/wsgi.py') diff --git a/repoze/bfg/wsgi.py b/repoze/bfg/wsgi.py index 26229836a..c576253b3 100644 --- a/repoze/bfg/wsgi.py +++ b/repoze/bfg/wsgi.py @@ -2,11 +2,11 @@ from repoze.bfg.compat import wraps from repoze.bfg.traversal import quote_path_segment def wsgiapp(wrapped): - """ Decorator to turn a WSGI application into a repoze.bfg view - callable. This decorator differs from the ``wsgiapp2`` decorator - inasmuch as fixups of ``PATH_INFO`` and ``SCRIPT_NAME`` within the - WSGI environment *are not* performed before the application is - invoked. + """ Decorator to turn a WSGI application into a :mod:`repoze.bfg` + :term:`view callable`. This decorator differs from the + :func:`repoze.bfg.wsgi.wsgiapp2` decorator inasmuch as fixups of + ``PATH_INFO`` and ``SCRIPT_NAME`` within the WSGI environment *are + not* performed before the application is invoked. E.g., the following in a ``views.py`` module:: @@ -24,14 +24,16 @@ def wsgiapp(wrapped): name="hello_world.txt" /> - Or the following :term:`Configurator` ``add_view`` method call:: + Or the following call to + :meth:`repoze.bfg.configuration.Configurator.add_view`:: from views import hello_world config.add_view(hello_world, name='hello_world.txt') - The wsgiapp decorator will convert the result of the WSGI - application to a Response and return it to repoze.bfg as if the - WSGI app were a repoze.bfg view. + The ``wsgiapp`` decorator will convert the result of the WSGI + application to a :term:`Response` and return it to + :mod:`repoze.bfg` as if the WSGI app were a :mod:`repoze.bfg` + view. """ def decorator(context, request): @@ -39,11 +41,11 @@ def wsgiapp(wrapped): return wraps(wrapped)(decorator) # grokkability def wsgiapp2(wrapped): - """ Decorator to turn a WSGI application into a repoze.bfg view - callable. This decorator differs from the ``wsgiapp`` decorator - inasmuch as fixups of ``PATH_INFO`` and ``SCRIPT_NAME`` within the - WSGI environment *are* performed before the application is - invoked. + """ Decorator to turn a WSGI application into a :mod:`repoze.bfg` + view callable. This decorator differs from the + :func:`repoze.bfg.wsgi.wsgiapp` decorator inasmuch as fixups of + ``PATH_INFO`` and ``SCRIPT_NAME`` within the WSGI environment + *are* performed before the application is invoked. E.g. the following in a ``views.py`` module:: @@ -61,17 +63,18 @@ def wsgiapp2(wrapped): name="hello_world.txt" /> - Or the following :term:`Configurator` ``add_view`` method call:: + Or the following call to + :meth:`repoze.bfg.configuration.Configurator.add_view`:: from views import hello_world config.add_view(hello_world, name='hello_world.txt') - The wsgiapp2 decorator will convert the result of the WSGI - application to a Response and return it to repoze.bfg as if the - WSGI app were a repoze.bfg view. The ``SCRIPT_NAME`` and - ``PATH_INFO`` values present in the WSGI environment are fixed up - before the application is invoked. - """ + The ``wsgiapp2`` decorator will convert the result of the WSGI + application to a Response and return it to :mod:`repoze.bfg` as if + the WSGI app were a :mod:`repoze.bfg` view. The ``SCRIPT_NAME`` + and ``PATH_INFO`` values present in the WSGI environment are fixed + up before the application is invoked. """ + def decorator(context, request): traversed = request.traversed vroot_path = request.virtual_root_path or () -- cgit v1.2.3