-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use a single response object #571
Comments
Does anyone have objections? I'd like to do this before Pando 1.0. |
Whether |
I'm not looking to prevent the raising of response objects, I'm only proposing that we use a single response object per request instead of creating new ones when raising. |
Also, ideally the developer should be able to replace the |
To clarify further, this is what I'm trying of get rid of: https://github.com/liberapay/liberapay.com/blob/134/liberapay/main.py#L139-L183 |
I'd like to still be able to raise |
It's not the creation of new instances that's the problem, but the global import. If we pass the |
Yes, however subclassing The first issue is that the The bigger problem is that when you're creating new instances you're throwing away every modification that previous functions may have made to the response object already in the state, such as adding cookies. I've hit this problem in Liberapay, and it seems to me that the best way to fix it is to use a single response object. |
Hmm ... I would expect the opposite: What does it look like to raise the if False:
response.code = 400
response.body = b'you bad'
raise response or maybe ... response.raise_with(400, b'you bad') ?
|
Then I suggest |
However, when you're doing |
I do want to make it clear that I'm raising. What about framing it in terms of the request? raise request.terminate(400, 'you bad') The point is that this is as far as the request is going to get. From here on out we're on our way back out to the browser.
|
Or |
raise EndOfRequest(400, 'you bad') |
raise request.End(400, 'you bad') |
I like that last one. |
I think it's weird. It's like the defunct |
Okay. Well, we've got a few options out on the table. I'm happy to let you decide. :-) |
It just occurred to me that having a single response object is incompatible with #304. |
Reticketed from #222 (comment):
The text was updated successfully, but these errors were encountered: