#24215: Refactor of lazy model operations
-------------------------------------+-------------------------------------
Reporter: AlexHill | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: 1.8alpha1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by AlexHill):
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Old description:
> I dealt with `add_lazy_relation()` a few months ago working on Mezzanine
> and I thought it could use some detangling.
>
> Now that the list of pending operations is stored in the Apps class, it
> makes sense to put the related methods on that class as well. Running a
> function when a model is loaded seems an appropriate job for the app
> registry object.
>
> I've introduced a more generic API, whereby a user-supplied function can
> be called once any number of models are ready, with those freshly-loaded
> models as its arguments (plus optional kwargs), a helper function for
> related models, and the old `add_lazy_relation()` reimplemented in terms
> of the new API with a deprecation warning.
New description:
I dealt with `add_lazy_relation()` a few months ago working on Mezzanine
and I thought it could use some detangling.
Now that the list of pending operations is stored in the `Apps` class, it
makes sense to put the related methods on that class as well. Running a
function when a model is loaded seems an appropriate job for the app
registry object.
I've introduced a more generic API, whereby a user-supplied function can
be called once any number of models are ready, with those freshly-loaded
models as its arguments (plus optional kwargs), a helper function for
related models, and the old `add_lazy_relation()` reimplemented in terms
of the new API with a deprecation warning.
Pull request at https://github.com/django/django/pull/3984
--
--
Ticket URL: <https://code.djangoproject.com/ticket/24215#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/066.576dcc477ddfb0ccd02d5f213b8b3215%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.