reddit/baseplate.py

Changing the body of a response object after the baseplate tween has run causes no content to be returned

Closed this issue · 2 comments

Between v1.4 and v1.5, Pyramid applications that map an exception to a view (@view_config(context=MyException)) lost the ability to control the body of the response. In fact, the body appears to be completely blank always in this case.

Minimal reproduction: https://github.com/reddit/baseplate.py/compare/develop...spladug:exception-body-disappears-when-streaming?expand=1

It appears to have been introduced in #489

Spent some time digging into this today. It looks like HTTPException classes set their own body/app_iter after we've patched our app_iter wrapper on. This theoretically could happen with custom response objects too so it's not just specific to this case.

I'm looking at ways of patching the app_iter property so that writes to it are proxied through the wrapper object, but this is all quite brittle and attached to the guts of webob's response object.

Closed by #739