Merge lp:~cjwatson/lazr.restful/py3-params-ordering into lp:lazr.restful

Proposed by Colin Watson
Status: Merged
Merged at revision: 292
Proposed branch: lp:~cjwatson/lazr.restful/py3-params-ordering
Merge into: lp:lazr.restful
Diff against target: 79 lines (+14/-5)
4 files modified
NEWS.rst (+7/-0)
setup.py (+1/-1)
src/lazr/restful/declarations.py (+3/-2)
src/lazr/restful/docs/webservice-declarations.rst (+3/-2)
To merge this branch: bzr merge lp:~cjwatson/lazr.restful/py3-params-ordering
Reviewer Review Type Date Requested Status
Cristian Gonzalez (community) Approve
Review via email: mp+398129@code.launchpad.net

Commit message

Preserve specified parameter ordering in export_factory_operation.

Description of the change

Preserve specified parameter ordering in export_factory_operation and BaseResourceOperationAdapter. This can make a difference when creating objects, by ensuring that validators are called in the correct order.

To post a comment you must log in.
Revision history for this message
Cristian Gonzalez (cristiangsp) wrote :

Looks good!

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-21 14:33:34 +0000
3+++ NEWS.rst 2021-02-16 16:53:00 +0000
4@@ -2,6 +2,13 @@
5 NEWS for lazr.restful
6 =====================
7
8+1.0.1
9+=====
10+
11+Preserve specified parameter ordering in ``export_factory_operation`` and
12+``BaseResourceOperationAdapter``. This can make a difference when creating
13+objects, by ensuring that validators are called in the correct order.
14+
15 1.0.0 (2021-01-21)
16 ==================
17
18
19=== modified file 'setup.py'
20--- setup.py 2021-01-21 11:48:06 +0000
21+++ setup.py 2021-02-16 16:53:00 +0000
22@@ -61,7 +61,7 @@
23 'pytz',
24 'setuptools',
25 'simplejson>=2.1.0',
26- 'six>=1.12.0',
27+ 'six>=1.13.0',
28 'testtools',
29 'van.testing',
30 'wsgiref; python_version < "3"',
31
32=== modified file 'src/lazr/restful/declarations.py'
33--- src/lazr/restful/declarations.py 2020-08-17 11:46:51 +0000
34+++ src/lazr/restful/declarations.py 2021-02-16 16:53:00 +0000
35@@ -43,6 +43,7 @@
36 'webservice_error',
37 ]
38
39+from collections import OrderedDict
40 import copy
41 import itertools
42 import sys
43@@ -1019,7 +1020,7 @@
44 # pylint: disable-msg=W0231
45 _check_called_from_interface_def('%s()' % self.__class__.__name__)
46 self.interface = interface
47- self.params = {}
48+ self.params = OrderedDict()
49 for name in field_names:
50 field = interface.get(name)
51 if field is None:
52@@ -1519,7 +1520,7 @@
53 (param_def.__name__, orig_name)
54 for orig_name, param_def in self._export_info['params'].items()
55 if param_def.__name__ != orig_name)
56- params = {}
57+ params = OrderedDict()
58 for name, value in kwargs.items():
59 name = renames.get(name, name)
60 params[name] = value
61
62=== modified file 'src/lazr/restful/docs/webservice-declarations.rst'
63--- src/lazr/restful/docs/webservice-declarations.rst 2021-01-18 11:58:31 +0000
64+++ src/lazr/restful/docs/webservice-declarations.rst 2021-02-16 16:53:00 +0000
65@@ -56,11 +56,12 @@
66 elements.
67
68 >>> from pprint import pformat
69+ >>> from six.moves.collections_abc import Mapping
70 >>> def print_export_tag(element):
71 ... """Print the content of the 'lazr.restful.exported' tag."""
72 ... def format_value(value):
73- ... if isinstance(value, dict):
74- ... return pformat(value, width=40)
75+ ... if isinstance(value, Mapping):
76+ ... return pformat(dict(value), width=40)
77 ... else:
78 ... return repr(value)
79 ... tag = element.queryTaggedValue('lazr.restful.exported')

Subscribers

People subscribed via source and target branches