Merge lp:~cjwatson/lazr.restful/py3-html-entry-sort-by-name into lp:lazr.restful

Proposed by Colin Watson
Status: Merged
Merged at revision: 283
Proposed branch: lp:~cjwatson/lazr.restful/py3-html-entry-sort-by-name
Merge into: lp:lazr.restful
Diff against target: 31 lines (+4/-1)
2 files modified
NEWS.rst (+2/-0)
src/lazr/restful/_resource.py (+2/-1)
To merge this branch: bzr merge lp:~cjwatson/lazr.restful/py3-html-entry-sort-by-name
Reviewer Review Type Date Requested Status
Thiago F. Pappacena (community) Approve
Review via email: mp+396621@code.launchpad.net

Commit message

Sort fields in HTML views of entries by name.

Description of the change

The old code caused test failures on Python 3, since dicts are no longer orderable.

To post a comment you must log in.
Revision history for this message
Thiago F. Pappacena (pappacena) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS.rst'
2--- NEWS.rst 2021-01-20 11:23:16 +0000
3+++ NEWS.rst 2021-01-20 23:54:56 +0000
4@@ -18,6 +18,8 @@
5 ``lazr.restful.testing.webservice.pprint_collection`` recurse into lists in
6 order to print text string representations in the Python 3 style.
7
8+Sort fields in HTML views of entries by name.
9+
10 0.23.0 (2020-09-28)
11 ===================
12
13
14=== modified file 'src/lazr/restful/_resource.py'
15--- src/lazr/restful/_resource.py 2020-09-24 10:01:25 +0000
16+++ src/lazr/restful/_resource.py 2021-01-20 23:54:56 +0000
17@@ -33,6 +33,7 @@
18 from datetime import datetime, date
19 from email.utils import formatdate
20 import copy
21+from operator import itemgetter
22 import os
23 import simplejson
24 import simplejson.encoder
25@@ -988,7 +989,7 @@
26 HTTPResource.XHTML_TYPE).items()
27 data = [{'name' : name, 'value': decode_value(value)}
28 for name, value in names_and_values]
29- namespace['context'] = sorted(data)
30+ namespace['context'] = sorted(data, key=itemgetter('name'))
31 return self.HTML_TEMPLATE.pt_render(namespace)
32
33

Subscribers

People subscribed via source and target branches