-
Notifications
You must be signed in to change notification settings - Fork 82
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
Logging issue on "raise httpexceptions.HTTPFound(url)" #319
Comments
We don't recommend raising That being said, this is still a bug in the debugtoolbar and we will look at it. |
I agree with everything @bertjwregeer said about this issue. |
"We don't recommend raising HTTPFound" who is "we" in this sentence? According to pyramid documentation HTTPFound can be returned from view or can be raised: https://docs.pylonsproject.org/projects/pyramid/en/latest/narr/views.html#using-a-view-callable-to-do-an-http-redirect I prefer to raise exception objects, not return them... because they are exceptions (they are located in httpexceptions module). And I don't use pyramid_tm(I have my own transaction manager, capable to distinguish "redirect" exceptions and commit transaction if they are raised). |
Well I mean we are both core Pyramid developers and I personally maintain pyramid_tm, pyramid_debugtoolbar, pyramid_retry, and quite a few others - so it's not like it's random advice.
To be clear No one is saying you can't raise them, and the core docs themselves tend to stay away from opinions on third party libraries like pyramid_tm, but in general we do recommend returning them due to issues with raising in "non error conditions" like the fact that pyramid_tm will, by default, abort your transaction. |
I have never thought that it was "random advice". I just tried to understand it more detailed. Because pyramid docs told about ability to raise "redirect exceptions" and ... they are exceptions. Maybe pyramid docs should be updated. Explaining possible drawback from raising "redirects" instead of returning them.
I am using my own transaction manager, because or requirement to handle more than 1 DB connection at a time. Maybe pyramid_tm is capable to do it now. And maybe I should give it one more chance. |
It's certainly possible - I'd be happy to review any pull requests to that effect. It's a classic example of "you can" but "should you?" is always a question of how the rest of your system is setup and it's hard to deal with all of those scenarios.
Yes the pyramid_tm tween is a generic wrapper around an in-memory transaction manager.. it does not define any data backends (such as your RDBMS or message queue etc). It allows many / arbitrary data mangers to hook into it and the manager will coordinate talking to them to perform a commit / abort. It can do this is a two-phase manner. See https://zodb.readthedocs.io/en/latest/transactions.html and https://transaction.readthedocs.io/en/latest/ for some information about that. |
I just pushed a fix in #320... further investigation shows this bug was only on Python < 3.5. |
@surabujin Just thought I'd let you know that I released pyramid_tm 2.2 and if you set the |
Hi.
If view execute "raise httpexceptions.HTTPFound(url)" the traceback from logging module will appear in console (application started via pserve).
Traceback:
Looks like issue lies in incorrect(at least for python3.4) call logging.exception. pyramid_debugtoolbar pass exc_info tuple into logging.exception method.
But if you take a look on this method:
you will see, that exc_info is replaces with "True".
Environment:
$ python --version
Python 3.4.3
pyramid_debugtoolbar > 4.0.1
PS Despite logging.exception issue - do we really need to catch/report raises of redirect exceptions?
The text was updated successfully, but these errors were encountered: