diff options
| author | Chris McDonough <chrism@plope.com> | 2011-06-04 18:43:25 -0400 |
|---|---|---|
| committer | Chris McDonough <chrism@plope.com> | 2011-06-04 18:43:25 -0400 |
| commit | df15ed98612e7962e3122da52d8d5f5b9d8882b2 (patch) | |
| tree | b862f334a286fd0545a134a73c89d295a57d7a64 /CHANGES.txt | |
| parent | 71738bc9418170cebfd532fbed6bb48ac8c3fb40 (diff) | |
| download | pyramid-df15ed98612e7962e3122da52d8d5f5b9d8882b2.tar.gz pyramid-df15ed98612e7962e3122da52d8d5f5b9d8882b2.tar.bz2 pyramid-df15ed98612e7962e3122da52d8d5f5b9d8882b2.zip | |
- It is now possible to control how the Pyramid router calls the WSGI
``start_response`` callable and obtains the WSGI ``app_iter`` based on
adapting the response object to the new ``pyramid.interfaces.IResponder``
interface. The default ``IResponder`` uses Pyramid 1.0's logic to do this.
To override the responder::
from pyramid.interfaces import IResponder
from pyramid.response import Response
from myapp import MyResponder
config.registry.registerAdapter(MyResponder, (Response,),
IResponder, name='')
This makes it possible to reuse response object implementations which have,
for example, their own ``__call__`` expected to be used as a WSGI
application (like ``pyramid.response.Response``), e.g.:
class MyResponder(object):
def __init__(self, response):
""" Obtain a reference to the response """
self.response = response
def __call__(self, request, start_response):
""" Call start_response and return an app_iter """
app_iter = self.response(request.environ, start_response)
return app_iter
Diffstat (limited to 'CHANGES.txt')
| -rw-r--r-- | CHANGES.txt | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 15c86c13c..7840bc525 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -132,6 +132,32 @@ Features - The ``pyramid.request.Response`` class now has a ``RequestClass`` interface which points at ``pyramid.response.Request``. +- It is now possible to control how the Pyramid router calls the WSGI + ``start_response`` callable and obtains the WSGI ``app_iter`` based on + adapting the response object to the new ``pyramid.interfaces.IResponder`` + interface. The default ``IResponder`` uses Pyramid 1.0's logic to do this. + To override the responder:: + + from pyramid.interfaces import IResponder + from pyramid.response import Response + from myapp import MyResponder + + config.registry.registerAdapter(MyResponder, (Response,), + IResponder, name='') + + This makes it possible to reuse response object implementations which have, + for example, their own ``__call__`` expected to be used as a WSGI + application (like ``pyramid.response.Response``), e.g.: + + class MyResponder(object): + def __init__(self, response): + """ Obtain a reference to the response """ + self.response = response + def __call__(self, request, start_response): + """ Call start_response and return an app_iter """ + app_iter = self.response(request.environ, start_response) + return app_iter + Bug Fixes --------- |
