We have a bunch of 500 errors since URL like
https://badges.fedoraproject.org/user/misc?history_limit=42 generate
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
comprehensions.
* 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
https://stackoverflow.com/questions/38987/how-to-merge-two-dictionaries-in-a-single-expression
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
AGPL project.
Signed-off-by: Adam Williamson <awilliam@redhat.com>
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
the history.
In tandem this page was put in the Wayback machine hosted by the
Internet Archive in the event of link rot:
https://web.archive.org/web/20190418175812/https://wiki.mozilla.org/BadgesResolves#424
Signed-off-by: Brian 'Redbeard' Harrington <redbeard@dead-city.org>
This commit adds the file that CentOS CI will look for to add CI
testing on Tahrir pull requests.
Signed-off-by: Randy Barlow <randy@electronsweatshop.com>
This commit adds tox as the Tahrir test runner. It ensures that
the unit tests pass, that new code has test coverage, and that the
docs build.
Signed-off-by: Randy Barlow <randy@electronsweatshop.com>
Tahrir did not have a test suite. This commit adds a single test
to get Tahrir started on the road to glory.
Signed-off-by: Randy Barlow <randy@electronsweatshop.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
project.
Signed-off-by: Randy Barlow <randy@electronsweatshop.com>
The backend bits of moksha are py3 ready, but the moksha.wsgi piece is not, plus it has some hairy deps that still need to be ported:
http://fedora.portingdb.xyz/pkg/python-moksha-wsgi/
Let's retire it. Removing it here to facilitate that.
For people with many badges, this brings down the user json generation
from >50 seconds to <4 seconds.
Signed-off-by: Patrick Uiterwijk <patrick@puiterwijk.org>