I think that for doing this you should modify response.render to a specialized function.
def my_response_render(*args, **kwargs):
# here you have to implement what you need
# and then do the normal response.render
in models/db.py
response.render = my_response_render
In that way you can intercept things before the response get rendered.
** maybe it can be included as a signal in response.render itself.
--

