Other dict related magic methods like `__getitem__`, `__setitem__` and
`__delitem__` are supported but not `__iter__`. I can't think of a reason
it isn't there and haven't been able to find discussions about it. The
`__getitem__`, `__setitem__` and `__delitem__` were added in this ticket:
https://code.djangoproject.com/ticket/18447
I think they just forgot `__iter__`. I'm proposing to add this. If this is
done, then tickets like these:
https://code.djangoproject.com/ticket/23783
Can be resolved with `SimpleLazyObject` (which implements `LazyObject`).
--
Ticket URL: <https://code.djangoproject.com/ticket/23838>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* version: 1.6 => master
* needs_tests: => 0
* needs_docs: => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/23838#comment:1>
* type: Uncategorized => New feature
--
Ticket URL: <https://code.djangoproject.com/ticket/23838#comment:2>
* cc: gitaarik@… (added)
* status: new => assigned
* owner: nobody => rednaw
--
Ticket URL: <https://code.djangoproject.com/ticket/23838#comment:3>
* cc: gitaarik@… (removed)
Comment:
Created a pull request:
https://github.com/django/django/pull/3541
--
Ticket URL: <https://code.djangoproject.com/ticket/23838#comment:4>
* component: Uncategorized => Utilities
Comment:
As I noted on the pull request, the new tests pass even before the fix is
applied so either there is no issue here or the test needs to be modified
to actually show what issue is fixed.
--
Ticket URL: <https://code.djangoproject.com/ticket/23838#comment:5>
* needs_better_patch: 0 => 1
* has_patch: 0 => 1
* type: New feature => Cleanup/optimization
* stage: Unreviewed => Accepted
Comment:
Hi,
The feature looks reasonable but as noted by Tim, the tests need some
improvement.
Thanks.
--
Ticket URL: <https://code.djangoproject.com/ticket/23838#comment:6>
Comment (by rednaw):
I updated my pull request, the test now fails when `__iter__` is not
implemented in `LazyObject`, so it's a good unit test now.
--
Ticket URL: <https://code.djangoproject.com/ticket/23838#comment:7>
* needs_better_patch: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/23838#comment:8>
* stage: Accepted => Ready for checkin
Comment:
New tests check for {{{__iter__}}} and fail with old implementation;
commit message is fine, lgtm.
The old test was already covered by the actual tests for
{{{__getitem__}}}.
--
Ticket URL: <https://code.djangoproject.com/ticket/23838#comment:9>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"a5b225084f69e27b78fab0f2954fa9520656976e"]:
{{{
#!CommitTicketReference repository=""
revision="a5b225084f69e27b78fab0f2954fa9520656976e"
Fixed #23838 -- added missing `__iter__` to LazyObject
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/23838#comment:10>