diff options
| author | Chris McDonough <chrism@agendaless.com> | 2009-12-24 01:26:37 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2009-12-24 01:26:37 +0000 |
| commit | c6895b23b63365a983cf564fc67446913ef2bebd (patch) | |
| tree | 1b679908dcf9a360f3250603eb8fedd23f46a144 /repoze/bfg/wsgi.py | |
| parent | 18e5d6c8fe922bf23ccbd481d60de294d7671103 (diff) | |
| download | pyramid-c6895b23b63365a983cf564fc67446913ef2bebd.tar.gz pyramid-c6895b23b63365a983cf564fc67446913ef2bebd.tar.bz2 pyramid-c6895b23b63365a983cf564fc67446913ef2bebd.zip | |
Roles.
Diffstat (limited to 'repoze/bfg/wsgi.py')
| -rw-r--r-- | repoze/bfg/wsgi.py | 45 |
1 files changed, 24 insertions, 21 deletions
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 () |
