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
=== modified file 'NEWS.rst'
--- NEWS.rst 2021-01-20 11:23:16 +0000
+++ NEWS.rst 2021-01-20 23:54:56 +0000
@@ -18,6 +18,8 @@
18``lazr.restful.testing.webservice.pprint_collection`` recurse into lists in18``lazr.restful.testing.webservice.pprint_collection`` recurse into lists in
19order to print text string representations in the Python 3 style.19order to print text string representations in the Python 3 style.
2020
21Sort fields in HTML views of entries by name.
22
210.23.0 (2020-09-28)230.23.0 (2020-09-28)
22===================24===================
2325
2426
=== modified file 'src/lazr/restful/_resource.py'
--- src/lazr/restful/_resource.py 2020-09-24 10:01:25 +0000
+++ src/lazr/restful/_resource.py 2021-01-20 23:54:56 +0000
@@ -33,6 +33,7 @@
33from datetime import datetime, date33from datetime import datetime, date
34from email.utils import formatdate34from email.utils import formatdate
35import copy35import copy
36from operator import itemgetter
36import os37import os
37import simplejson38import simplejson
38import simplejson.encoder39import simplejson.encoder
@@ -988,7 +989,7 @@
988 HTTPResource.XHTML_TYPE).items()989 HTTPResource.XHTML_TYPE).items()
989 data = [{'name' : name, 'value': decode_value(value)}990 data = [{'name' : name, 'value': decode_value(value)}
990 for name, value in names_and_values]991 for name, value in names_and_values]
991 namespace['context'] = sorted(data)992 namespace['context'] = sorted(data, key=itemgetter('name'))
992 return self.HTML_TEMPLATE.pt_render(namespace)993 return self.HTML_TEMPLATE.pt_render(namespace)
993994
994995

Subscribers

People subscribed via source and target branches