Merge lp://staging/~cjwatson/storm/py3-listify-resultset into lp://staging/storm

Proposed by Colin Watson
Status: Merged
Merged at revision: 553
Proposed branch: lp://staging/~cjwatson/storm/py3-listify-resultset
Merge into: lp://staging/storm
Diff against target: 147 lines (+72/-2)
5 files modified
NEWS (+8/-0)
setup.py (+1/-0)
storm/store.py (+3/-0)
storm/tests/zope/README.txt (+53/-0)
storm/zope/configure.zcml (+7/-2)
To merge this branch: bzr merge lp://staging/~cjwatson/storm/py3-listify-resultset
Reviewer Review Type Date Requested Status
Simon Poirier (community) Approve
Review via email: mp+382961@code.staging.launchpad.net

Commit message

Fix list() on security-proxied ResultSets on Python 3.

Description of the change

On Python 3, list() calls len() internally to preallocate the correct amount of space if possible. If __len__ is unimplemented, then it falls back to guessing, but ForbiddenAttribute confuses it and results in failing to create the list. Allowing __len__ through the security proxy, even though it's unimplemented, avoids this.

(We don't want to implement ResultSet.__len__ in terms of ResultSet.count because it would make it too easy to write code that implicitly issued extra SQL queries. On the other hand, EmptyResultSet.__len__ can trivially be implemented, so do so here.)

To post a comment you must log in.
555. By Colin Watson

Allow SQLObjectResultSet.__len__ too.

Revision history for this message
Simon Poirier (simpoir) wrote :

+1 LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches

to status/vote changes: