Opened 11 years ago

Closed 11 years ago

#20924 closed Bug (fixed)

LazyObject missing __contains__ and __len__ proxy

Reported by: nickbruun Owned by: nobody
Component: Utilities Version: 1.5
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

django.utils.functionals.LazyObject does not proxy the __contains__ and __len__ data methods. This means that the following use cases for lazy objects that return lists, sets or dicts are not possible:

key in lazy_object
len(lazy_object)

Fixing this is trivial as has been shown by the current proxying implementation of __getitem__, __setitem__ and __delitem__. Regression test and patch is available on Github at https://github.com/nickbruun/django.

Change History (6)

in reply to:  description comment:1 by nickbruun, 11 years ago

comment:2 by Tim Graham, 11 years ago

Patch needs improvement: set
Triage Stage: UnreviewedAccepted

Please untick "Patch needs improvement" when you can update the PR per the comment, thanks!

comment:3 by nickbruun, 11 years ago

Patch needs improvement: unset

comment:4 by nickbruun, 11 years ago

Patch needs improvement: set

comment:5 by nickbruun, 11 years ago

Patch needs improvement: unset

Patch updated.

comment:6 by anonymous, 11 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top