# pyramid.wsgi¶

wsgiapp(wrapped)[source]

Decorator to turn a WSGI application into a Pyramid view callable. This decorator differs from the pyramid.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:

@wsgiapp
def hello_world(environ, start_response):
body = 'Hello world'
start_response('200 OK', [ ('Content-Type', 'text/plain'),
('Content-Length', len(body)) ] )
return [body]


Allows the following call to pyramid.config.Configurator.add_view():

from views import hello_world


The wsgiapp decorator will convert the result of the WSGI application to a Response and return it to Pyramid as if the WSGI app were a Pyramid view.

wsgiapp2(wrapped)[source]

Decorator to turn a WSGI application into a Pyramid view callable. This decorator differs from the pyramid.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:

@wsgiapp2
def hello_world(environ, start_response):
body = 'Hello world'
start_response('200 OK', [ ('Content-Type', 'text/plain'),
('Content-Length', len(body)) ] )
return [body]


Allows the following call to pyramid.config.Configurator.add_view():

from views import hello_world

The wsgiapp2 decorator will convert the result of the WSGI application to a Response and return it to Pyramid as if the WSGI app were a Pyramid view. The SCRIPT_NAME and PATH_INFO values present in the WSGI environment are fixed up before the application is invoked. In particular, a new WSGI environment is generated, and the subpath of the request passed to wsgiapp2 is used as the new request's PATH_INFO and everything preceding the subpath is used as the SCRIPT_NAME. The new environment is passed to the downstream WSGI application.