-
Notifications
You must be signed in to change notification settings - Fork 25
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
addressing ZODB/issues/12, encode request.path_info
before passing it to transaction.note
#25
Conversation
…fore passing it to `transaction.note`
request.path_info
before passing it to transaction.note
request.path_info
before passing it to transaction.note
Sorry I haven't run the tests. I guess my fix breaks Python 3 compatibility... |
t.note(request.path_info) | ||
except UnicodeDecodeError: | ||
t.note("Unable to decode path as unicode") | ||
t.note(str(request.path_info)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably needs something like the pyramid.compat.text_
function.
Thanks for the pointing, Tres. I made it with |
ok, I'll add |
Can someone point me if I need to improve the patch. Is it too naive? I really want to contribute! |
@@ -3,7 +3,7 @@ | |||
|
|||
from pyramid.util import DottedNameResolver | |||
from pyramid.tweens import EXCVIEW | |||
from pyramid_tm.compat import reraise | |||
from pyramid_tm.compat import reraise, compat_str |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't this just use pyramid.compat.bytes_
? That function already handles the if PY3:
case correctly, and its name makes it clear that you mean to be passing bytes to t.note()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was done initially in commit d902b85, but it failed tests in py3 environment. To be honest - I am not qualified enough in py3, so I moved the call under if
check. But I got your point, I'll try to remove extra check and function call...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I've looked at it: Transaction.note()
requires a native string (not bytes as I first thought). Fortunately, the transaction
package provides a helper for that:
from transaction._compat import native_
#...
t.note(native_(request.path_info))
That would allow us to drop the changes to pyramid_tm/compat.py
.
We do need to add a test which exercises this behavior: one each passing unicode and bytes to `tm_tween'.
* implemented `transaction._compat.native_` * added two tests for unicode and str path
* implemented `transaction._compat.native_` * added two tests for unicode and str path
Tres, please review. I didn't manage to avoid PY3 check in one of the tests I've added, but I hope its acceptable. Sorry for the commit spam - I don't have py3 env and relied on Travis output. |
addressing ZODB/issues/12, encode `request.path_info`before passing it to `transaction.note`
Thank you! |
Thank you for quick response! |
As discussed in zopefoundation/ZODB#12 I too have unicode urls in my project and this issue blocks me when I try to update a context object with unicode in path_info
This update of mine fixes the problem, though I'm not sure if I didn't break anything else.