We have a bunch of 500 errors since URL like
a link to user/misc?history_limit=42/rss, which in turn cause trouble
since 42/rss can't be turned into a int, generating a traceback:
File "/usr/lib/python2.7/site-packages/pyramid/router.py", line 163, in handle_request
response = view_callable(context, request)
File "/usr/lib/python2.7/site-packages/pyramid/config/views.py", line 355, in rendered_view
result = view(context, request)
File "/usr/lib/python2.7/site-packages/pyramid/config/views.py", line 501, in _requestonly_view
response = view(request)
File "/usr/lib/python2.7/site-packages/tahrir/views.py", line 1042, in user
history_limit = int(request.params.get('history_limit', 10))
ValueError: invalid literal for int() with base 10: '42/rss'
This does enough Python 3 porting to make Tahrir run and do some
basic stuff under Python 3 - I've tested creating badges and
series, issuing badges, clicking around in Leaderboard and
Explore, looking at RSS and JSON views of things. This does not
break Python 2 compatibility - I'd rather not do that yet so we
can test things easily both ways and identify any differences.
We could remove Python 2 compat later.
Most of the changes are based on 2to3 suggestions and are pretty
self-explanatory. Some less obvious ones:
* The str_to_bytes and dogpile stuff: well, see
https://github.com/sqlalchemy/dogpile.cache/issues/159 . The
`sha1_mangle_key` mangler that we're using, which is provided by
dogpile, needs input as a bytestring. This is pretty awkward. It
obviously caused *some* problems even in Python 2 (as this app
explicitly uses unicodes in some places), but in Python 3 it's
worse; everywhere you see `str_to_bytes` being called is a place
where I found a crash because we wound up sending a non-encoded
`str` to `sha1_mangle_key` (or, in the case of `email_md5` and
`email_sha1`, to hashlib directly).
* map moved in Python 3; 2to3 suggests handling it with a six
move, but I preferred just replacing all the `map` uses with
* 2to3 recommended a change to strip_tags, but I noticed it is
not actually used any more. It was used to sanitize HTML input
to the admin route back when it was added, but the admin route
was entirely rewritten later and the use of strip_tags was taken
out. So I just removed strip_tags and its supporting players.
* merge_dicts is used in places where we were merging two dicts
in a single expression by converting them to lists, combining
the lists, and turning the combined list back into a dict again.
You can still do this in Python 3 but you have to add extra
`list()` calls and it gets really ugly. Per
it's also not resource-efficient, so this seems like a better
approach - it's informed by the code in that SO question but I
wrote the function myself rather than taking one from that page
to avoid technically having a tiny bit of CC-BY-SA code in this
Signed-off-by: Adam Williamson <firstname.lastname@example.org>
Update all links to move from the mozilla wiki to openbadges.org.
Additionally, add a historic note and (since the link to the mozilla
wiki is in danger of being purged) changing it to a specific revision in
In tandem this page was put in the Wayback machine hosted by the
Internet Archive in the event of link rot:
Signed-off-by: Brian 'Redbeard' Harrington <email@example.com>
Sphix emits a warning if two links use the same target name. For
example, prior to this commit there was a Sphinx warning:
docs/index.rst:2:Duplicate explicit target name: "here".
This commit makes it so there are no Sphinx warnings in the docs
Signed-off-by: Randy Barlow <firstname.lastname@example.org>