I have a method decorated with the following decorators: @request.restful() @auth.requires_login()
On an unauthenticated (non-logged-in) request, I get a 403 response with "Not authorized" in the response body, per default settings. I would like to be able to modify this response to be JSON. I've tried modifying the following auth.settings as follows: def json_response(): import json raise HTTP(403, json.dumps(dict(content='Not authorized'))) auth.settings.on_failed_authentication = json_response auth.settings.on_failed_authorization = json_response However, I continue to receive the "Not authorized" string in the response to the RESTful method instead of the JSON. Upon further digging, I found line 3448 in gluon/tools.py with the following: elif self.settings.allow_basic_login_only or \ basic_accepted or current.request.is_restful: raise HTTP(403, "Not authorized") It seems like methods with the @request.restful() decorator simply cannot be overridden to return a custom response on unauthenticated requests, at least without modifying tools.py. Is this correct? Thanks ahead of time for any help. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.