Hi, I feel like I'm going around in circles trying to figure out how
to serve JSON error documents for my jsonified controllers. I'm using
0.9.6.1 and I've been following:
http://wiki.pylonshq.com/display/pylonsdocs/Error+Documents
I put a json template string in
<app>.controllers.error.ErrorController but I have two questions [so
far] :
1. What's a good way to decide whether or not I want to send a JSON
response or an HTML response? I was thinking
pylons.response.headers['Content-Type'] but it seems that even though
@jsonify is setting the Content-Type, something is resetting it. I'll
try to dig into that tomorrow.
2. How the heck do I test this? I really really don't want to create
a jsonified controller method in my real app just to raise an error
for a test. I want to create a small controller in my test module and
then somehow configure ErrorDocuments with my very own
<app>.controllers.error ... but I'm having a hard time finding where
that magic occurs. So far I have a mess of a file, with pieces from
Pylon's own unit tests, setting up a test app like this:
environ = { 'paste.throw_errors': False, 'debug': False }
app = ControllerWrap(JsonController)
app = ErrorHandler(app, environ, error_template=error_template,
debug=False, show_exceptions_in_wsgi_errors=True)
app = ErrorDocuments(app, environ, mapper=error_mapper)
app = sap = SetupCacheGlobal(app, environ)
app = RegistryManager(app)
app = TestApp(app)
... with JsonController being the one that does a little abort(500,
'internal server error'). I suppose I need to connect
/error/document/ to my other controller with routes somehow? Or maybe
just unit test the ErrorController?
thanks,
Kumar
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---