Merge lp:~leonardr/launchpad/new-lazr.restful-and-friends into lp:launchpad/db-devel

Proposed by Leonard Richardson
Status: Merged
Approved by: Paul Hummer
Approved revision: no longer in the source branch.
Merged at revision: 9671
Proposed branch: lp:~leonardr/launchpad/new-lazr.restful-and-friends
Merge into: lp:launchpad/db-devel
Diff against target: 258 lines (+67/-28)
8 files modified
lib/canonical/launchpad/doc/batch_navigation.txt (+15/-9)
lib/canonical/launchpad/pagetests/webservice/launchpadlib.txt (+2/-1)
lib/canonical/launchpad/pagetests/webservice/multiversion.txt (+32/-1)
lib/canonical/launchpad/rest/configuration.py (+1/-0)
lib/lp/bugs/stories/webservice/xx-bug.txt (+8/-8)
lib/lp/registry/stories/webservice/xx-structuralsubscription.txt (+2/-2)
lib/lp/soyuz/stories/webservice/xx-packageset.txt (+1/-1)
versions.cfg (+6/-6)
To merge this branch: bzr merge lp:~leonardr/launchpad/new-lazr.restful-and-friends
Reviewer Review Type Date Requested Status
Guilherme Salgado (community) code Approve
Paul Hummer (community) Approve
Review via email: mp+32474@code.launchpad.net

Description of the change

This branch integrates new versions of many other libraries into Launchpad: launchpadlib, lazr.batchnavigator, lazr.delegates, lazr.restful, lazr.restfulclient, and wadllib. A couple of these (lazr.delegates and wadllib) are just due for a refresh. The other changes are necessary to have the "devel" version of the web service switch from serving total_size_link to serving total_size.

Note the changes made to the tests having to do with changes to lazr.batchnavigator. A SELECT COUNT query is no longer made unless you explicitly ask for the length of a queryset. And an empty collection has a 'start' of 0 instead of None.

To post a comment you must log in.
Revision history for this message
Paul Hummer (rockstar) :
review: Approve
Revision history for this message
Leonard Richardson (leonardr) wrote :

I need a follow-up review. I integrated a new version of lazr.restful into it and added an end-to-end test to prevent another bug like the one that almost slipped through.

http://paste.ubuntu.com/477538/

Revision history for this message
Guilherme Salgado (salgado) wrote :

Looks good to me

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/launchpad/doc/batch_navigation.txt'
2--- lib/canonical/launchpad/doc/batch_navigation.txt 2009-08-21 17:43:28 +0000
3+++ lib/canonical/launchpad/doc/batch_navigation.txt 2010-08-18 13:47:45 +0000
4@@ -69,27 +69,33 @@
5 >>> email_batch = batch_nav.currentBatch()
6 >>> batch_items = list(email_batch)
7
8-Because we're only looking at the first batch, the database is only asked for
9-the number of rows, and the first 10 rows:
10+Because we're only looking at the first batch, the database is only
11+asked for the first 11 rows. (lazr.batchnavigator asks for 11 instead
12+of 10 so that it can reliably detect the end of the dataset).
13
14 >>> len(CursorWrapper.last_executed_sql)
15- 2
16- >>> print CursorWrapper.last_executed_sql[1]
17- SELECT ... FROM EmailAddress ... LIMIT 10...
18+ 1
19 >>> print CursorWrapper.last_executed_sql[0]
20- SELECT COUNT(*) FROM EmailAddress
21+ SELECT ... FROM EmailAddress ... LIMIT 11...
22
23-Get the next 10. The database is only asked for the next 10 rows -- no further
24-COUNTs are issued:
25+Get the next 10. The database is only asked for the next 11 rows:
26
27 >>> CursorWrapper.last_executed_sql = []
28 >>> email_batch2 = email_batch.nextBatch()
29 >>> batch_items = list(email_batch2)
30 >>> len(CursorWrapper.last_executed_sql)
31 1
32- >>> CursorWrapper.last_executed_sql[0].endswith('LIMIT 10 OFFSET 10')
33+ >>> CursorWrapper.last_executed_sql[0].endswith('LIMIT 11 OFFSET 10')
34 True
35
36+As seen above, simply accessing the batch doesn't trigger a SQL query
37+asking for the length. But explicitly asking for the length will
38+trigger a SQL query.
39+
40+ >>> CursorWrapper.last_executed_sql = []
41+ >>> ignored = email_batch.total()
42+ >>> print CursorWrapper.last_executed_sql[0]
43+ SELECT COUNT(*) FROM EmailAddress
44
45 Multiple pages
46 ==============
47
48=== modified file 'lib/canonical/launchpad/pagetests/webservice/launchpadlib.txt'
49--- lib/canonical/launchpad/pagetests/webservice/launchpadlib.txt 2010-07-07 20:42:22 +0000
50+++ lib/canonical/launchpad/pagetests/webservice/launchpadlib.txt 2010-08-18 13:47:45 +0000
51@@ -71,7 +71,8 @@
52 >>> print lp_anon.me.name
53 Traceback (most recent call last):
54 ...
55- HTTPError: HTTP Error 401: Unauthorized...
56+ Unauthorized: HTTP Error 401: Unauthorized...
57+
58
59 Caching
60 =======
61
62=== modified file 'lib/canonical/launchpad/pagetests/webservice/multiversion.txt'
63--- lib/canonical/launchpad/pagetests/webservice/multiversion.txt 2010-03-05 19:03:12 +0000
64+++ lib/canonical/launchpad/pagetests/webservice/multiversion.txt 2010-08-18 13:47:45 +0000
65@@ -1,5 +1,36 @@
66+****************************
67 Differences between versions
68-----------------------------
69+****************************
70+
71+total_size_link
72+===============
73+
74+In the 'devel' version of the web service, named operations that
75+return collections will return a 'total_size_link' pointing to the
76+total size of the collection.
77+
78+ >>> def get_collection(version):
79+ ... collection = webservice.get(
80+ ... "/people?ws.op=find&text=salgado", api_version=version)
81+ ... return collection.jsonBody()
82+
83+ >>> collection = get_collection("devel")
84+ >>> print sorted(collection.keys())
85+ [u'entries', u'start', u'total_size_link']
86+ >>> print webservice.get(collection['total_size_link']).jsonBody()
87+ 1
88+
89+In previous versions, the same named operations will return a
90+'total_size' containing the actual size of the collection.
91+
92+ >>> collection = get_collection("1.0")
93+ >>> print sorted(collection.keys())
94+ [u'entries', u'start', u'total_size']
95+ >>> print collection['total_size']
96+ 1
97+
98+Mutator operations
99+==================
100
101 In the 'beta' version of the web service, mutator methods like
102 IBugTask.transitionToStatus are published as named operations. In
103
104=== modified file 'lib/canonical/launchpad/rest/configuration.py'
105--- lib/canonical/launchpad/rest/configuration.py 2010-06-03 16:37:27 +0000
106+++ lib/canonical/launchpad/rest/configuration.py 2010-08-18 13:47:45 +0000
107@@ -25,6 +25,7 @@
108 path_override = "api"
109 active_versions = ["beta", "1.0", "devel"]
110 last_version_with_mutator_named_operations = "beta"
111+ first_version_with_total_size_link = "devel"
112 view_permission = "launchpad.View"
113 compensate_for_mod_compress_etag_modification = True
114
115
116=== modified file 'lib/lp/bugs/stories/webservice/xx-bug.txt'
117--- lib/lp/bugs/stories/webservice/xx-bug.txt 2010-06-30 21:19:36 +0000
118+++ lib/lp/bugs/stories/webservice/xx-bug.txt 2010-08-18 13:47:45 +0000
119@@ -572,7 +572,7 @@
120 ... firefox_bugtask['self_link'],
121 ... 'findSimilarBugs')
122 HTTP/1.1 200 Ok...
123- {"total_size": 0, "start": null, "entries": []}
124+ {"total_size": 0, "start": 0, "entries": []}
125
126 If we add a new bug that's quite similar to others, findSimilarBugs()
127 will return something more useful.
128@@ -626,7 +626,7 @@
129
130 >>> pprint_collection(webservice.named_get(
131 ... '/bugs/%d' % bug.id, 'getNominations').jsonBody())
132- start: None
133+ start: 0
134 total_size: 0
135 ---
136
137@@ -1216,7 +1216,7 @@
138 ... bug_one['attachments_collection_link']).jsonBody()
139 >>> pprint_collection(attachments)
140 resource_type_link: u'http://.../#bug_attachment-page-resource'
141- start: None
142+ start: 0
143 total_size: 0
144 ---
145
146@@ -1348,7 +1348,7 @@
147 ... bug_one['attachments_collection_link']).jsonBody()
148 >>> pprint_collection(attachments)
149 resource_type_link: u'http://api.launchpad.dev/beta/#bug_attachment-page-resource'
150- start: None
151+ start: 0
152 total_size: 0
153 ---
154
155@@ -1433,7 +1433,7 @@
156 ... '/ubuntu', 'searchTasks',
157 ... tags=['crash', 'dataloss'],
158 ... tags_combinator='All').jsonBody())
159- start: None
160+ start: 0
161 total_size: 0
162 ---
163
164@@ -1442,7 +1442,7 @@
165 >>> pprint_collection(webservice.named_get(
166 ... '/ubuntu', 'searchTasks',
167 ... modified_since=u'2011-01-01T00:00:00+00:00').jsonBody())
168- start: None
169+ start: 0
170 total_size: 0
171 ---
172
173@@ -1684,7 +1684,7 @@
174 ... '/~testuser3', 'searchTasks'
175 ... ).jsonBody()
176 >>> pprint_collection(related)
177- start: None
178+ start: 0
179 total_size: 0
180 ---
181
182@@ -1841,7 +1841,7 @@
183 HTTP/1.1 200 Ok...
184 >>> pprint_collection(webservice.get(bug_one_cves_url).jsonBody())
185 resource_type_link: u'http://.../#cve-page-resource'
186- start: None
187+ start: 0
188 total_size: 0
189 ---
190
191
192=== modified file 'lib/lp/registry/stories/webservice/xx-structuralsubscription.txt'
193--- lib/lp/registry/stories/webservice/xx-structuralsubscription.txt 2009-12-24 01:41:54 +0000
194+++ lib/lp/registry/stories/webservice/xx-structuralsubscription.txt 2010-08-18 13:47:45 +0000
195@@ -22,7 +22,7 @@
196 >>> subscriptions = webservice.named_get(
197 ... '/fooix', 'getSubscriptions').jsonBody()
198 >>> pprint_collection(subscriptions)
199- start: None
200+ start: 0
201 total_size: 0
202 ---
203
204@@ -146,6 +146,6 @@
205 >>> subscriptions = webservice.named_get(
206 ... '/fooix', 'getSubscriptions').jsonBody()
207 >>> pprint_collection(subscriptions)
208- start: None
209+ start: 0
210 total_size: 0
211 ---
212
213=== modified file 'lib/lp/soyuz/stories/webservice/xx-packageset.txt'
214--- lib/lp/soyuz/stories/webservice/xx-packageset.txt 2009-11-04 00:00:09 +0000
215+++ lib/lp/soyuz/stories/webservice/xx-packageset.txt 2010-08-18 13:47:45 +0000
216@@ -197,7 +197,7 @@
217 >>> print response
218 HTTP/1.1 200 Ok
219 ...
220- {"total_size": 0, "start": null, "entries": []}
221+ {"total_size": 0, "start": 0, "entries": []}
222
223 Let's create a few more package sets and set up a package set hierarchy.
224
225
226=== modified file 'versions.cfg'
227--- versions.cfg 2010-08-12 21:02:08 +0000
228+++ versions.cfg 2010-08-18 13:47:45 +0000
229@@ -24,15 +24,15 @@
230 grokcore.component = 1.6
231 httplib2 = 0.6.0
232 ipython = 0.9.1
233-launchpadlib = 1.6.0
234+launchpadlib = 1.6.4
235 lazr.authentication = 0.1.1
236-lazr.batchnavigator = 1.1.1
237+lazr.batchnavigator = 1.2.1
238 lazr.config = 1.1.3
239-lazr.delegates = 1.1.0
240+lazr.delegates = 1.2.0
241 lazr.enum = 1.1.2
242 lazr.lifecycle = 1.1
243-lazr.restful = 0.9.29
244-lazr.restfulclient = 0.9.14
245+lazr.restful = 0.11.1
246+lazr.restfulclient = 0.10.0
247 lazr.smtptest = 1.1
248 lazr.testing = 0.1.1
249 lazr.uri = 1.0.2
250@@ -71,7 +71,7 @@
251 Twisted = 10.1.0
252 uuid = 1.30
253 van.testing = 2.0.1
254-wadllib = 1.1.4
255+wadllib = 1.1.5
256 webunit = 1.3.8
257 # r1440 of lp:~bjornt/windmill/1.3-lp. It includes our patches to make test
258 # setup and tear down more robust, which didn't make it into the 1.3 release.

Subscribers

People subscribed via source and target branches

to status/vote changes: