baseplate.py icon indicating copy to clipboard operation
baseplate.py copied to clipboard

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

Open spladug opened this issue 3 years ago • 1 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 https://github.com/reddit/baseplate.py/pull/489

spladug avatar Mar 13 '21 00:03 spladug

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.

spladug avatar Mar 16 '21 23:03 spladug

Closed by #739

maeivysea avatar Sep 13 '22 22:09 maeivysea