Merge lp:~leonardr/launchpad/optimized-length-2 into lp:launchpad/db-devel

Proposed by Leonard Richardson
Status: Merged
Approved by: Aaron Bentley
Approved revision: no longer in the source branch.
Merged at revision: 9705
Proposed branch: lp:~leonardr/launchpad/optimized-length-2
Merge into: lp:launchpad/db-devel
Diff against target: 126 lines (+51/-21)
3 files modified
lib/canonical/launchpad/pagetests/webservice/datamodel.txt (+29/-19)
lib/canonical/launchpad/webapp/batching.py (+20/-0)
versions.cfg (+2/-2)
To merge this branch: bzr merge lp:~leonardr/launchpad/optimized-length-2
Reviewer Review Type Date Requested Status
Michael Nelson (community) code Approve
Graham Binns (community) code Approve
Aaron Bentley (community) Approve
Review via email: mp+33417@code.launchpad.net

Description of the change

This branch integrates the newest version of lazr.restful, which sends 'total_size' instead of 'total_size_link' if it's easy to figure out the total size of a collection. The changes to datamodel.txt show when this happens.

To post a comment you must log in.
Revision history for this message
Aaron Bentley (abentley) :
review: Approve
Revision history for this message
Leonard Richardson (leonardr) wrote :

I need a follow-up review. I fixed a minor test failure and added a workaround for bug 620508. I'm fairly sure it won't screw up anything else, but the tests will say for sure.

Revision history for this message
Graham Binns (gmb) wrote :

r=me for r11392.

review: Approve (code)
Revision history for this message
Michael Nelson (michael.nelson) wrote :

r=me for the change pasted via irc:

14:51 < noodles775> leonardr: I don't see a one-liner? It's r11442 that needs to be reviewed right? This: http://bazaar.launchpad.net/~leonardr/launchpad/optimized-length-2/revision/11442
14:59 < leonardr> noodles775, 11442 corrects a typo made to the original one-liner. i was hoping to just give you the code so it wouldn't be so complicated
14:59 < leonardr> i'll just do another merge proposal and get in the queue
15:01 < noodles775> leonardr: I'm happy to review just the one-line that's changed, but currently I can only see it in 11442 along with a few other changes. If the rest is already reviewed, just paste a diff and I can review that, otherwise yes, a new MP is probably easier.
15:04 < leonardr> noodles775: i see the problem. i had to create a new branch with the old changes, so all the old changes show up as one revision
15:04 < leonardr> this code is the only code that hasn't been reviewed yet:
15:04 < leonardr> + if hasattr(resultset, '_select'):
15:04 < leonardr> + resultset._select.limit = Undef
15:04 < leonardr> + resultset._select.offset = Undef
15:05 < noodles775> leonardr: r=me (I assume the second two lines were there previously, just not indented). Thanks!
15:05 < leonardr> noodles, yeah

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/pagetests/webservice/datamodel.txt'
--- lib/canonical/launchpad/pagetests/webservice/datamodel.txt 2010-08-19 14:38:10 +0000
+++ lib/canonical/launchpad/pagetests/webservice/datamodel.txt 2010-08-26 12:53:02 +0000
@@ -7,29 +7,39 @@
7end-to-end tests of code paths that, on the surface, look like they're7end-to-end tests of code paths that, on the surface, look like they're
8already tested in lazr.restful.8already tested in lazr.restful.
99
10 >>> def get_collection(version, start=0, size=2):10 >>> def get_collection(version="devel", start=0, size=2):
11 ... collection = webservice.get(11 ... collection = webservice.get(
12 ... ("/people?ws.op=find&text=s&ws.start=%s&ws.size=%s" %12 ... ("/people?ws.op=find&text=s&ws.start=%s&ws.size=%s" %
13 ... (start, size)),13 ... (start, size)),
14 ... api_version=version)14 ... api_version=version)
15 ... return collection.jsonBody()15 ... return collection.jsonBody()
1616
17Even if an entire collection fits on one page (so that the total size17
18of the collection is obvious), 'total_size_link' will be served18Normally, the total size of a collection is not served along with the
19instead of 'total_size'. (It would be nice to fix this.)19collection; it's available by following the total_size_link.
2020
21 >>> collection = get_collection("devel", size=100)21 >>> collection = get_collection()
22 >>> print sorted(collection.keys())22 >>> print sorted(collection.keys())
23 [u'entries', u'start', u'total_size_link']23 [u'entries', u'next_collection_link', u'start', u'total_size_link']
24 >>> print webservice.get(collection['total_size_link']).jsonBody()24 >>> print webservice.get(collection['total_size_link']).jsonBody()
25 925 9
2626
27Even if the last page of the collection is fetched (so that the total27If an entire collection fits on one page (making the size of the
28size of the collection is semi-obvious), 'total_size_link' will be28collection obvious), 'total_size' is served instead of
29served instead of 'total_size'. (It would be nice to fix this.)29'total_size_link'.
3030
31 >>> collection = get_collection("devel", start=8)31 >>> collection = get_collection(size=100)
32 >>> print sorted(collection.keys())32 >>> print sorted(collection.keys())
33 [u'entries', u'prev_collection_link', u'start', u'total_size_link']33 [u'entries', u'start', u'total_size']
34 >>> print webservice.get(collection['total_size_link']).jsonBody()34 >>> print collection['total_size']
35 9
36
37If the last page of the collection is fetched (making the total size
38of the collection semi-obvious), 'total_size' is served instead of
39'total_size_link'.
40
41 >>> collection = get_collection(start=8)
42 >>> print sorted(collection.keys())
43 [u'entries', u'prev_collection_link', u'start', u'total_size']
44 >>> print collection['total_size']
35 945 9
3646
=== modified file 'lib/canonical/launchpad/webapp/batching.py'
--- lib/canonical/launchpad/webapp/batching.py 2010-08-20 20:31:18 +0000
+++ lib/canonical/launchpad/webapp/batching.py 2010-08-26 12:53:02 +0000
@@ -4,11 +4,13 @@
4__metaclass__ = type4__metaclass__ = type
55
6import lazr.batchnavigator6import lazr.batchnavigator
7from storm import Undef
7# and ISQLObjectResultSet8# and ISQLObjectResultSet
8from storm.zope.interfaces import IResultSet9from storm.zope.interfaces import IResultSet
9from zope.component import adapts10from zope.component import adapts
10from zope.interface import implements11from zope.interface import implements
11from zope.interface.common.sequence import IFiniteSequence12from zope.interface.common.sequence import IFiniteSequence
13from zope.security.proxy import removeSecurityProxy
1214
13from canonical.config import config15from canonical.config import config
14from canonical.launchpad.webapp.interfaces import ITableBatchNavigator16from canonical.launchpad.webapp.interfaces import ITableBatchNavigator
@@ -30,6 +32,24 @@
30 return iter(self.context)32 return iter(self.context)
3133
32 def __len__(self):34 def __len__(self):
35 # XXX 2010-08-24 leonardr bug=620508
36 #
37 # Slicing a ResultSet object returns a copy with ._limit and
38 # ._offset set appropriately. The original object's ._limit
39 # and ._offset are not affected. However, the original and
40 # the copy share a _select object, which means the original
41 # object's ._select.limit and ._select.offset are shared with
42 # the copy.
43 #
44 # This breaks Storm--count() is not supported on a ResultSet
45 # that has a limit or offset set. This code sets
46 # ._select.limit and ._select.offset to the appropriate values
47 # before running the count() query, just as __getitem__ sets
48 # those values before running its query.
49 resultset = removeSecurityProxy(self.context)
50 if hasattr(resultset, '_select'):
51 resultset._select.limit = Undef
52 resultset._select.offset = Undef
33 return self.context.count()53 return self.context.count()
3454
3555
3656
=== modified file 'versions.cfg'
--- versions.cfg 2010-08-25 18:51:51 +0000
+++ versions.cfg 2010-08-26 12:53:02 +0000
@@ -24,14 +24,14 @@
24grokcore.component = 1.624grokcore.component = 1.6
25httplib2 = 0.6.025httplib2 = 0.6.0
26ipython = 0.9.126ipython = 0.9.1
27launchpadlib = 1.6.427launchpadlib = 1.6.5
28lazr.authentication = 0.1.128lazr.authentication = 0.1.1
29lazr.batchnavigator = 1.2.229lazr.batchnavigator = 1.2.2
30lazr.config = 1.1.330lazr.config = 1.1.3
31lazr.delegates = 1.2.031lazr.delegates = 1.2.0
32lazr.enum = 1.1.232lazr.enum = 1.1.2
33lazr.lifecycle = 1.133lazr.lifecycle = 1.1
34lazr.restful = 0.11.134lazr.restful = 0.11.3
35lazr.restfulclient = 0.10.035lazr.restfulclient = 0.10.0
36lazr.smtptest = 1.136lazr.smtptest = 1.1
37lazr.testing = 0.1.137lazr.testing = 0.1.1

Subscribers

People subscribed via source and target branches

to status/vote changes: