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
=== modified file 'lib/canonical/launchpad/doc/batch_navigation.txt'
--- lib/canonical/launchpad/doc/batch_navigation.txt 2009-08-21 17:43:28 +0000
+++ lib/canonical/launchpad/doc/batch_navigation.txt 2010-08-18 13:47:45 +0000
@@ -69,27 +69,33 @@
69 >>> email_batch = batch_nav.currentBatch()69 >>> email_batch = batch_nav.currentBatch()
70 >>> batch_items = list(email_batch)70 >>> batch_items = list(email_batch)
7171
72Because we're only looking at the first batch, the database is only asked for72Because we're only looking at the first batch, the database is only
73the number of rows, and the first 10 rows:73asked for the first 11 rows. (lazr.batchnavigator asks for 11 instead
74of 10 so that it can reliably detect the end of the dataset).
7475
75 >>> len(CursorWrapper.last_executed_sql)76 >>> len(CursorWrapper.last_executed_sql)
76 277 1
77 >>> print CursorWrapper.last_executed_sql[1]
78 SELECT ... FROM EmailAddress ... LIMIT 10...
79 >>> print CursorWrapper.last_executed_sql[0]78 >>> print CursorWrapper.last_executed_sql[0]
80 SELECT COUNT(*) FROM EmailAddress79 SELECT ... FROM EmailAddress ... LIMIT 11...
8180
82Get the next 10. The database is only asked for the next 10 rows -- no further81Get the next 10. The database is only asked for the next 11 rows:
83COUNTs are issued:
8482
85 >>> CursorWrapper.last_executed_sql = []83 >>> CursorWrapper.last_executed_sql = []
86 >>> email_batch2 = email_batch.nextBatch()84 >>> email_batch2 = email_batch.nextBatch()
87 >>> batch_items = list(email_batch2)85 >>> batch_items = list(email_batch2)
88 >>> len(CursorWrapper.last_executed_sql)86 >>> len(CursorWrapper.last_executed_sql)
89 187 1
90 >>> CursorWrapper.last_executed_sql[0].endswith('LIMIT 10 OFFSET 10')88 >>> CursorWrapper.last_executed_sql[0].endswith('LIMIT 11 OFFSET 10')
91 True89 True
9290
91As seen above, simply accessing the batch doesn't trigger a SQL query
92asking for the length. But explicitly asking for the length will
93trigger a SQL query.
94
95 >>> CursorWrapper.last_executed_sql = []
96 >>> ignored = email_batch.total()
97 >>> print CursorWrapper.last_executed_sql[0]
98 SELECT COUNT(*) FROM EmailAddress
9399
94Multiple pages100Multiple pages
95==============101==============
96102
=== modified file 'lib/canonical/launchpad/pagetests/webservice/launchpadlib.txt'
--- lib/canonical/launchpad/pagetests/webservice/launchpadlib.txt 2010-07-07 20:42:22 +0000
+++ lib/canonical/launchpad/pagetests/webservice/launchpadlib.txt 2010-08-18 13:47:45 +0000
@@ -71,7 +71,8 @@
71 >>> print lp_anon.me.name71 >>> print lp_anon.me.name
72 Traceback (most recent call last):72 Traceback (most recent call last):
73 ...73 ...
74 HTTPError: HTTP Error 401: Unauthorized...74 Unauthorized: HTTP Error 401: Unauthorized...
75
7576
76Caching77Caching
77=======78=======
7879
=== modified file 'lib/canonical/launchpad/pagetests/webservice/multiversion.txt'
--- lib/canonical/launchpad/pagetests/webservice/multiversion.txt 2010-03-05 19:03:12 +0000
+++ lib/canonical/launchpad/pagetests/webservice/multiversion.txt 2010-08-18 13:47:45 +0000
@@ -1,5 +1,36 @@
1****************************
1Differences between versions2Differences between versions
2----------------------------3****************************
4
5total_size_link
6===============
7
8In the 'devel' version of the web service, named operations that
9return collections will return a 'total_size_link' pointing to the
10total size of the collection.
11
12 >>> def get_collection(version):
13 ... collection = webservice.get(
14 ... "/people?ws.op=find&text=salgado", api_version=version)
15 ... return collection.jsonBody()
16
17 >>> collection = get_collection("devel")
18 >>> print sorted(collection.keys())
19 [u'entries', u'start', u'total_size_link']
20 >>> print webservice.get(collection['total_size_link']).jsonBody()
21 1
22
23In previous versions, the same named operations will return a
24'total_size' containing the actual size of the collection.
25
26 >>> collection = get_collection("1.0")
27 >>> print sorted(collection.keys())
28 [u'entries', u'start', u'total_size']
29 >>> print collection['total_size']
30 1
31
32Mutator operations
33==================
334
4In the 'beta' version of the web service, mutator methods like35In the 'beta' version of the web service, mutator methods like
5IBugTask.transitionToStatus are published as named operations. In36IBugTask.transitionToStatus are published as named operations. In
637
=== modified file 'lib/canonical/launchpad/rest/configuration.py'
--- lib/canonical/launchpad/rest/configuration.py 2010-06-03 16:37:27 +0000
+++ lib/canonical/launchpad/rest/configuration.py 2010-08-18 13:47:45 +0000
@@ -25,6 +25,7 @@
25 path_override = "api"25 path_override = "api"
26 active_versions = ["beta", "1.0", "devel"]26 active_versions = ["beta", "1.0", "devel"]
27 last_version_with_mutator_named_operations = "beta"27 last_version_with_mutator_named_operations = "beta"
28 first_version_with_total_size_link = "devel"
28 view_permission = "launchpad.View"29 view_permission = "launchpad.View"
29 compensate_for_mod_compress_etag_modification = True30 compensate_for_mod_compress_etag_modification = True
3031
3132
=== modified file 'lib/lp/bugs/stories/webservice/xx-bug.txt'
--- lib/lp/bugs/stories/webservice/xx-bug.txt 2010-06-30 21:19:36 +0000
+++ lib/lp/bugs/stories/webservice/xx-bug.txt 2010-08-18 13:47:45 +0000
@@ -572,7 +572,7 @@
572 ... firefox_bugtask['self_link'],572 ... firefox_bugtask['self_link'],
573 ... 'findSimilarBugs')573 ... 'findSimilarBugs')
574 HTTP/1.1 200 Ok...574 HTTP/1.1 200 Ok...
575 {"total_size": 0, "start": null, "entries": []}575 {"total_size": 0, "start": 0, "entries": []}
576576
577If we add a new bug that's quite similar to others, findSimilarBugs()577If we add a new bug that's quite similar to others, findSimilarBugs()
578will return something more useful.578will return something more useful.
@@ -626,7 +626,7 @@
626626
627 >>> pprint_collection(webservice.named_get(627 >>> pprint_collection(webservice.named_get(
628 ... '/bugs/%d' % bug.id, 'getNominations').jsonBody())628 ... '/bugs/%d' % bug.id, 'getNominations').jsonBody())
629 start: None629 start: 0
630 total_size: 0630 total_size: 0
631 ---631 ---
632632
@@ -1216,7 +1216,7 @@
1216 ... bug_one['attachments_collection_link']).jsonBody()1216 ... bug_one['attachments_collection_link']).jsonBody()
1217 >>> pprint_collection(attachments)1217 >>> pprint_collection(attachments)
1218 resource_type_link: u'http://.../#bug_attachment-page-resource'1218 resource_type_link: u'http://.../#bug_attachment-page-resource'
1219 start: None1219 start: 0
1220 total_size: 01220 total_size: 0
1221 ---1221 ---
12221222
@@ -1348,7 +1348,7 @@
1348 ... bug_one['attachments_collection_link']).jsonBody()1348 ... bug_one['attachments_collection_link']).jsonBody()
1349 >>> pprint_collection(attachments)1349 >>> pprint_collection(attachments)
1350 resource_type_link: u'http://api.launchpad.dev/beta/#bug_attachment-page-resource'1350 resource_type_link: u'http://api.launchpad.dev/beta/#bug_attachment-page-resource'
1351 start: None1351 start: 0
1352 total_size: 01352 total_size: 0
1353 ---1353 ---
13541354
@@ -1433,7 +1433,7 @@
1433 ... '/ubuntu', 'searchTasks',1433 ... '/ubuntu', 'searchTasks',
1434 ... tags=['crash', 'dataloss'],1434 ... tags=['crash', 'dataloss'],
1435 ... tags_combinator='All').jsonBody())1435 ... tags_combinator='All').jsonBody())
1436 start: None1436 start: 0
1437 total_size: 01437 total_size: 0
1438 ---1438 ---
14391439
@@ -1442,7 +1442,7 @@
1442 >>> pprint_collection(webservice.named_get(1442 >>> pprint_collection(webservice.named_get(
1443 ... '/ubuntu', 'searchTasks',1443 ... '/ubuntu', 'searchTasks',
1444 ... modified_since=u'2011-01-01T00:00:00+00:00').jsonBody())1444 ... modified_since=u'2011-01-01T00:00:00+00:00').jsonBody())
1445 start: None1445 start: 0
1446 total_size: 01446 total_size: 0
1447 ---1447 ---
14481448
@@ -1684,7 +1684,7 @@
1684 ... '/~testuser3', 'searchTasks'1684 ... '/~testuser3', 'searchTasks'
1685 ... ).jsonBody()1685 ... ).jsonBody()
1686 >>> pprint_collection(related)1686 >>> pprint_collection(related)
1687 start: None1687 start: 0
1688 total_size: 01688 total_size: 0
1689 ---1689 ---
16901690
@@ -1841,7 +1841,7 @@
1841 HTTP/1.1 200 Ok...1841 HTTP/1.1 200 Ok...
1842 >>> pprint_collection(webservice.get(bug_one_cves_url).jsonBody())1842 >>> pprint_collection(webservice.get(bug_one_cves_url).jsonBody())
1843 resource_type_link: u'http://.../#cve-page-resource'1843 resource_type_link: u'http://.../#cve-page-resource'
1844 start: None1844 start: 0
1845 total_size: 01845 total_size: 0
1846 ---1846 ---
18471847
18481848
=== modified file 'lib/lp/registry/stories/webservice/xx-structuralsubscription.txt'
--- lib/lp/registry/stories/webservice/xx-structuralsubscription.txt 2009-12-24 01:41:54 +0000
+++ lib/lp/registry/stories/webservice/xx-structuralsubscription.txt 2010-08-18 13:47:45 +0000
@@ -22,7 +22,7 @@
22 >>> subscriptions = webservice.named_get(22 >>> subscriptions = webservice.named_get(
23 ... '/fooix', 'getSubscriptions').jsonBody()23 ... '/fooix', 'getSubscriptions').jsonBody()
24 >>> pprint_collection(subscriptions)24 >>> pprint_collection(subscriptions)
25 start: None25 start: 0
26 total_size: 026 total_size: 0
27 ---27 ---
2828
@@ -146,6 +146,6 @@
146 >>> subscriptions = webservice.named_get(146 >>> subscriptions = webservice.named_get(
147 ... '/fooix', 'getSubscriptions').jsonBody()147 ... '/fooix', 'getSubscriptions').jsonBody()
148 >>> pprint_collection(subscriptions)148 >>> pprint_collection(subscriptions)
149 start: None149 start: 0
150 total_size: 0150 total_size: 0
151 ---151 ---
152152
=== modified file 'lib/lp/soyuz/stories/webservice/xx-packageset.txt'
--- lib/lp/soyuz/stories/webservice/xx-packageset.txt 2009-11-04 00:00:09 +0000
+++ lib/lp/soyuz/stories/webservice/xx-packageset.txt 2010-08-18 13:47:45 +0000
@@ -197,7 +197,7 @@
197 >>> print response197 >>> print response
198 HTTP/1.1 200 Ok198 HTTP/1.1 200 Ok
199 ...199 ...
200 {"total_size": 0, "start": null, "entries": []}200 {"total_size": 0, "start": 0, "entries": []}
201201
202Let's create a few more package sets and set up a package set hierarchy.202Let's create a few more package sets and set up a package set hierarchy.
203203
204204
=== modified file 'versions.cfg'
--- versions.cfg 2010-08-12 21:02:08 +0000
+++ versions.cfg 2010-08-18 13:47:45 +0000
@@ -24,15 +24,15 @@
24grokcore.component = 1.624grokcore.component = 1.6
25httplib2 = 0.6.025httplib2 = 0.6.0
26ipython = 0.9.126ipython = 0.9.1
27launchpadlib = 1.6.027launchpadlib = 1.6.4
28lazr.authentication = 0.1.128lazr.authentication = 0.1.1
29lazr.batchnavigator = 1.1.129lazr.batchnavigator = 1.2.1
30lazr.config = 1.1.330lazr.config = 1.1.3
31lazr.delegates = 1.1.031lazr.delegates = 1.2.0
32lazr.enum = 1.1.232lazr.enum = 1.1.2
33lazr.lifecycle = 1.133lazr.lifecycle = 1.1
34lazr.restful = 0.9.2934lazr.restful = 0.11.1
35lazr.restfulclient = 0.9.1435lazr.restfulclient = 0.10.0
36lazr.smtptest = 1.136lazr.smtptest = 1.1
37lazr.testing = 0.1.137lazr.testing = 0.1.1
38lazr.uri = 1.0.238lazr.uri = 1.0.2
@@ -71,7 +71,7 @@
71Twisted = 10.1.071Twisted = 10.1.0
72uuid = 1.3072uuid = 1.30
73van.testing = 2.0.173van.testing = 2.0.1
74wadllib = 1.1.474wadllib = 1.1.5
75webunit = 1.3.875webunit = 1.3.8
76# r1440 of lp:~bjornt/windmill/1.3-lp. It includes our patches to make test76# r1440 of lp:~bjornt/windmill/1.3-lp. It includes our patches to make test
77# setup and tear down more robust, which didn't make it into the 1.3 release.77# 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: