Domhnall Walsh wrote:
> Hi there:
>
> Hopefully you guys can help me. I'm working on an application that needs
> to be able to selectively output JSON based on whether the submitted
> requestion specifies "application/json" in the request's 'Accept:'
> headers. I had a mechanism that worked okay in Pylons 0.9.6 based on a
> custom error_mapper in config/middleware.py, wrapped up in a nice little
> function I could call, but due to changes in how this works in Pylons
> 0.9.7 (I'm using RC4 on Python 2.5.1), which I've had to upgrade to for
> unrelated reasons, I'm a bit lost. I've found references to being able
> to do this by setting an environment variable
> ('pylons.status_code_redirect') in the docstrings for
> pylons.middleware.StatusCodeRedirect but I can't figure out how to apply
> this selectively rather than all the time. Can anyone shed some wisdom
> on this?
Well, the middleware does try not to respond with a full response when
it gets an XMLHttpRequest. I tells this because of X-Requested-With:
XMLHttpRequest. Another thing that suppresses the full response is a
GET variable _. If you want, we would accept a patch that checks the
Accept header and also uses that to give shortened errors (you could
look for those other checks as a place to introduce a new check).
--
Ian Bicking : [email protected] : http://blog.ianbicking.org
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---