Merge lp:~leonardr/lazr.restful/474522-oops-backport into lp:~lazr-developers/lazr.restful/oops-fix

Proposed by Leonard Richardson
Status: Merged
Merged at revision: not available
Proposed branch: lp:~leonardr/lazr.restful/474522-oops-backport
Merge into: lp:~lazr-developers/lazr.restful/oops-fix
Diff against target: 224 lines (+36/-24)
4 files modified
src/lazr/restful/NEWS.txt (+6/-0)
src/lazr/restful/docs/webservice-marshallers.txt (+26/-23)
src/lazr/restful/marshallers.py (+3/-0)
src/lazr/restful/version.txt (+1/-1)
To merge this branch: bzr merge lp:~leonardr/lazr.restful/474522-oops-backport
Reviewer Review Type Date Requested Status
Brad Crittenden (community) code Approve
Review via email: mp+14696@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Leonard Richardson (leonardr) wrote :

This branch backports my fix to bug 474522 to lazr.restful 0.9.13, so that it can be cherry-picked into production. It will be merged into a master "oops fix" branch that takes 0.9.13 as its base.

Revision history for this message
Brad Crittenden (bac) :
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 2009-10-19 17:27:37 +0000
3+++ src/lazr/restful/NEWS.txt 2009-11-10 15:55:20 +0000
4@@ -2,6 +2,12 @@
5 NEWS for lazr.restful
6 =====================
7
8+0.9.13.1 (2009-11-16)
9+=====================
10+
11+Fixed a bug that raised an unhandled exception when a client tried to
12+set a URL field to a non-string value.
13+
14 0.9.13 (2009-10-19)
15 ===================
16
17
18=== modified file 'src/lazr/restful/docs/webservice-marshallers.txt'
19--- src/lazr/restful/docs/webservice-marshallers.txt 2009-09-01 12:07:59 +0000
20+++ src/lazr/restful/docs/webservice-marshallers.txt 2009-11-10 15:55:20 +0000
21@@ -17,7 +17,6 @@
22 >>> request.setPublication(WebServiceTestPublication(application))
23 >>> request.processInputs()
24
25-==========================================
26 IFieldMarshaller and SimpleFieldMarshaller
27 ==========================================
28
29@@ -63,7 +62,6 @@
30 >>> print marshaller.marshall_from_json_data(None)
31 None
32
33-=======================
34 marshall_from_request()
35 =======================
36
37@@ -107,7 +105,6 @@
38 >>> marshaller.marshall_from_request(['value1', 'value2'])
39 ['value1', 'value2']
40
41-
42 unmarshall() and variants
43 =========================
44
45@@ -132,12 +129,11 @@
46 'foo'
47
48
49-================================
50 Marshallers for basic data types
51 ================================
52
53 Bool
54-====
55+----
56
57 The marshaller for a Bool field checks that the JSON value is either
58 True or False. A ValueError is raised when its not the case.
59@@ -188,7 +184,7 @@
60 ValueError: got 'str', expected bool: 'True'
61
62 Int
63-===
64+---
65
66 The marshaller for an Int field checks that the JSON value is an
67 integer. A ValueError is raised when its not the case.
68@@ -245,7 +241,7 @@
69 ValueError: got 'unicode', expected int: u'0x04'
70
71 Float
72-=====
73+-----
74
75 The marshaller for a Float field checks that the JSON value is indeed a
76 float. A ValueError is raised when it's not the case.
77@@ -290,7 +286,7 @@
78 ValueError: got 'str', expected float, int: 'True'
79
80 Datetime
81-========
82+--------
83
84 The marshaller for a Datetime field checks that the JSON value is indeed a
85 parsable datetime stamp.
86@@ -346,7 +342,7 @@
87 ValueError: Value doesn't look like a date.
88
89 Date
90-====
91+----
92
93 The marshaller for a Date field checks that the JSON value is indeed a
94 parsable date.
95@@ -367,7 +363,7 @@
96 datetime.date(2009, 7, 7)
97
98 Text
99-====
100+----
101
102 The marshaller for IText field checks that the value is a unicode
103 string. A ValueError is raised when that's not the case.
104@@ -412,7 +408,7 @@
105 None
106
107 Bytes
108-=====
109+-----
110
111 Since there is no way to represent a bytes string in JSON, all strings
112 are converted to a byte string using UTF-8 encoding. If the value isn't
113@@ -480,7 +476,6 @@
114 >>> marshaller.unmarshall(entry_resource, None)
115 'http://.../cookbooks/Everyday%20Greens/data'
116
117----------
118 ASCIILine
119 ---------
120
121@@ -502,7 +497,7 @@
122 >>> marshaller.marshall_from_json_data(u'int\xe9ressant')
123 u'int\xe9ressant'
124
125-Non-string alues like floats are rejected.
126+Non-string values like floats are rejected.
127
128 >>> marshaller.marshall_from_json_data(1.0)
129 Traceback (most recent call last):
130@@ -542,7 +537,6 @@
131 >>> marshaller.representation_name
132 'field'
133
134-==================
135 Choice marshallers
136 ==================
137
138@@ -552,7 +546,7 @@
139 >>> from zope.schema import Choice
140
141 Choice for IVocabularyTokenized
142-===============================
143+-------------------------------
144
145 The default marshaller will use the vocabulary getTermByToken to
146 retrieve the value to use. It raises an error if the value isn't in the
147@@ -595,9 +589,8 @@
148 [('title', None), ('token', 'a value')]
149 [('title', None), ('token', 'True')]
150
151-
152 Choice of EnumeratedTypes
153-=========================
154+-------------------------
155
156 The JSON representation of the enumerated value is its title. A string
157 that corresponds to one of the values is marshalled to the appropriate
158@@ -641,9 +634,8 @@
159 [('title', 'Vegetarian'), ('token', 'VEGETARIAN')]
160
161
162-=======
163 Objects
164-=======
165+-------
166
167 An object is marshalled to its URL.
168
169@@ -667,9 +659,21 @@
170 >>> cookbook.name
171 u'Mastering the Art of French Cooking'
172
173-===========
174+ >>> reference_marshaller.marshall_from_json_data("not a url")
175+ Traceback (most recent call last):
176+ ...
177+ ValueError: "not a url" is not a valid URI.
178+
179+ >>> reference_marshaller.marshall_from_json_data(4)
180+ Traceback (most recent call last):
181+ ...
182+ ValueError: got 'int', expected string: 4
183+
184+ >>> print reference_marshaller.marshall_from_json_data(None)
185+ None
186+
187 Collections
188-===========
189+-----------
190
191 The most complicated kind of marshaller is one that manages a
192 collection of objects associated with some other object. The generic
193@@ -787,9 +791,8 @@
194 >>> sorted(set_marshaller.unmarshall(None, marshalled_set))
195 ['Dessert', 'Vegetarian']
196
197-===============
198 CollectionField
199-===============
200+---------------
201
202 Since CollectionField are really a list of references to other
203 objects, and they are exposed using a dedicated CollectionResource,
204
205=== modified file 'src/lazr/restful/marshallers.py'
206--- src/lazr/restful/marshallers.py 2009-07-14 20:54:06 +0000
207+++ src/lazr/restful/marshallers.py 2009-11-10 15:55:20 +0000
208@@ -71,6 +71,9 @@
209 else:
210 request_port = default_port
211
212+ if not isinstance(url, basestring):
213+ raise ValueError("got '%s', expected string: %r" % (
214+ type(url).__name__, url))
215 uri = URI(url)
216 protocol = uri.scheme
217 host = uri.host
218
219=== modified file 'src/lazr/restful/version.txt'
220--- src/lazr/restful/version.txt 2009-10-15 15:32:57 +0000
221+++ src/lazr/restful/version.txt 2009-11-10 15:55:20 +0000
222@@ -1,1 +1,1 @@
223-0.9.13
224+0.9.13.1

Subscribers

People subscribed via source and target branches

to all changes: