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 ofPATH_INFO
andSCRIPT_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 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 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 ofPATH_INFO
andSCRIPT_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 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 Pyramid as if the WSGI app were a Pyramid view. TheSCRIPT_NAME
andPATH_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 towsgiapp2
is used as the new request'sPATH_INFO
and everything preceding the subpath is used as theSCRIPT_NAME
. The new environment is passed to the downstream WSGI application.