[Django] #19396: Allow customized ModelState classes

9 views
Skip to first unread message

Django

unread,
Nov 30, 2012, 6:17:00 AM11/30/12
to django-...@googlegroups.com
#19396: Allow customized ModelState classes
-------------------------------------+-------------------------------------
Reporter: akaariai | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version: master
Component: Database | Keywords:
layer (models, ORM) | Has patch: 1
Severity: Normal | Needs tests: 0
Triage Stage: | Easy pickings: 0
Unreviewed |
Needs documentation: 0 |
Patch needs improvement: 0 |
UI/UX: 0 |
-------------------------------------+-------------------------------------
By allowing classes to define customized ModelState classes and by
introducing some hooks into model saving custom Model subclasses can
implement some often requested things:
- Automatic primary key updates
- Save only changed data
- Proper optimistic locking

Two of the above ideas are implemented in the added tests in
https://github.com/akaariai/django/compare/akaariai:model_save_refactor...akaariai:model_state_improvements.
The patch is based on model_save_refactor from #16649.

The cost of this is a performance penalty of a 3-5% for instantiating
single-field models from DB (query_all benchmark of djangobench), less for
multi-field models.

I'd like to keep this private API for a while until more is known about
what kinds of states are needed.

--
Ticket URL: <https://code.djangoproject.com/ticket/19396>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 20, 2012, 1:06:23 AM12/20/12
to django-...@googlegroups.com
#19396: Allow customized ModelState classes
-------------------------------------+-------------------------------------
Reporter: akaariai | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version: master
Component: Database layer | Resolution:
(models, ORM) | Triage Stage: Design
Severity: Normal | decision needed
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by russellm):

* stage: Unreviewed => Design decision needed


Comment:

Seems like a reasonable idea on the face of it, but needs some more
discussion before we formally accept the idea.

--
Ticket URL: <https://code.djangoproject.com/ticket/19396#comment:1>

Django

unread,
Mar 24, 2013, 2:23:37 PM3/24/13
to django-...@googlegroups.com
#19396: Allow customized ModelState classes
-------------------------------------+-------------------------------------
Reporter: akaariai | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version: master
Component: Database layer | Resolution:
(models, ORM) | Triage Stage: Accepted
Severity: Normal | Needs documentation: 0
Keywords: | Patch needs improvement: 0
Has patch: 1 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by apollo13):

* stage: Design decision needed => Accepted


Comment:

I think it would be great to have.

--
Ticket URL: <https://code.djangoproject.com/ticket/19396#comment:2>

Django

unread,
Jun 13, 2014, 8:26:47 PM6/13/14
to django-...@googlegroups.com
#19396: Allow customized ModelState classes
-------------------------------------+-------------------------------------
Reporter: akaariai | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version: master
Component: Database layer | Resolution:
(models, ORM) | Triage Stage: Accepted
Severity: Normal | Needs documentation: 0
Keywords: | Patch needs improvement: 1

Has patch: 1 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by timo):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/19396#comment:3>

Reply all
Reply to author
Forward
0 new messages