Merge lp:~stevenk/lazr.restful/lazr.restful-choice-marshaller-none into lp:lazr.restful

Proposed by Steve Kowalik on 2012-10-23
Status: Merged
Approved by: Steve Kowalik on 2012-10-23
Approved revision: 203
Merged at revision: 203
Proposed branch: lp:~stevenk/lazr.restful/lazr.restful-choice-marshaller-none
Merge into: lp:lazr.restful
Diff against target: 72 lines (+17/-5)
4 files modified
src/lazr/restful/NEWS.txt (+5/-0)
src/lazr/restful/docs/webservice-marshallers.txt (+9/-1)
src/lazr/restful/marshallers.py (+2/-3)
src/lazr/restful/version.txt (+1/-1)
To merge this branch: bzr merge lp:~stevenk/lazr.restful/lazr.restful-choice-marshaller-none
Reviewer Review Type Date Requested Status
William Grant code 2012-10-23 Approve on 2012-10-23
Review via email: mp+130932@code.launchpad.net

Description of the Change

Deal with None as a value in FixedVocabularyFieldMarshaller.unmarshall_to_closeup(). We only use it to see if the value is currently selected, so skipping that if the value is None seems reasonable.

Re-add a print to the test I added in 0.19.8, without it the test fails.

To post a comment you must log in.
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/lazr/restful/NEWS.txt'
2--- src/lazr/restful/NEWS.txt 2012-10-01 23:18:46 +0000
3+++ src/lazr/restful/NEWS.txt 2012-10-23 04:43:22 +0000
4@@ -2,6 +2,11 @@
5 NEWS for lazr.restful
6 =====================
7
8+0.19.9 (2012-10-23)
9+
10+Fixed bug 924291: The FixedVocabularyFieldMarshaller will now correctly return
11+the entire vocabulary if the value passed in is None.
12+
13 0.19.8 (2012-10-02)
14 ===================
15
16
17=== modified file 'src/lazr/restful/docs/webservice-marshallers.txt'
18--- src/lazr/restful/docs/webservice-marshallers.txt 2012-09-27 07:17:42 +0000
19+++ src/lazr/restful/docs/webservice-marshallers.txt 2012-10-23 04:43:22 +0000
20@@ -590,6 +590,14 @@
21 [('title', None), ('token', 'a value')]
22 [('title', None), ('token', 'True')]
23
24+And None is handled correctly.
25+
26+ >>> for token in marshaller.unmarshall_to_closeup(None, None):
27+ ... print sorted(token.items())
28+ [('title', None), ('token', '10')]
29+ [('title', None), ('token', 'a value')]
30+ [('title', None), ('token', 'True')]
31+
32 Unicode Exceptions Sidebar
33 --------------------------
34
35@@ -906,7 +914,7 @@
36
37 The unmarshall() method will return None when given None.
38
39- >>> dict_marshaller.unmarshall(None, None)
40+ >>> print dict_marshaller.unmarshall(None, None)
41 None
42
43 CollectionField
44
45=== modified file 'src/lazr/restful/marshallers.py'
46--- src/lazr/restful/marshallers.py 2012-09-27 07:17:42 +0000
47+++ src/lazr/restful/marshallers.py 2012-10-23 04:43:22 +0000
48@@ -321,15 +321,14 @@
49 part of a multiadapter lookup of the appropriate
50 marshaller.
51 """
52- super(FixedVocabularyFieldMarshaller, self).__init__(
53- field, request)
54+ super(FixedVocabularyFieldMarshaller, self).__init__(field, request)
55
56 def unmarshall_to_closeup(self, entry, value):
57 """Describe all values, not just the selected value."""
58 unmarshalled = []
59 for item in self.field.vocabulary:
60 item_dict = {'token': item.token, 'title': item.title}
61- if value.title == item.title:
62+ if value and value.title == item.title:
63 item_dict['selected'] = True
64 unmarshalled.append(item_dict)
65 return unmarshalled
66
67=== modified file 'src/lazr/restful/version.txt'
68--- src/lazr/restful/version.txt 2012-09-27 07:12:12 +0000
69+++ src/lazr/restful/version.txt 2012-10-23 04:43:22 +0000
70@@ -1,1 +1,1 @@
71-0.19.8
72+0.19.9

Subscribers

People subscribed via source and target branches