FWIW, this was on my mind a few years ago and I created this [1] ticket. It
spidered out into one or two more, but the basic ideas were:

* optimistic locking could be implemented by enhancing saves with
conditions (i.e., save_if)
* a row-modified count could help that function also tell you if the save
condition passed or failed
* rows modified *may* be used now to update data via QuerySet.update, but
allegedly not all of the DB implementations provide the count in the same
way (e.g., matched vs. updated)
* the modified count discrepancy was worth spinning up another ticket to
discuss and investigate

I agree with Russell, I think the need for this is much broader than the
admin.

[1] https://code.djangoproject.com/ticket/16549

On Mon Dec 08 2014 at 7:10:28 PM Russell Keith-Magee <
[email protected]> wrote:

> Hi Rune,
>
> I agree with Tim. This is clearly a problem that exists, and I agree it
> would be good to fix it. However, I wouldn't want to see this as an "Admin
> only" fix.
>
> I'd rather see a generic hook that Admin then leverages as the "first
> customer". A similar approach was taken with object-level permissions - a
> generic framework for object-level permissions was added, and admin was
> modified to support that API as part of the proof that the API was
> sufficient.
>
> From an implementation perspective, I also have a mild negative reaction
> to the idea of using a separate table in the database for locks. Using a
> database row to marshal this behavior sounds like adding load to a database
> when all you need is a transient marker. A backend API that lets you use
> memcache, redis, or even a file-based backend might be called for. And
> that's assuming we take the "separate lock table" approach - I can think of
> other approaches that involve version indicators on the model itself. These
> are just initial impressions, however; I haven't given the problem a whole
> lot of thought, so these might not be viable ideas given a little more
> consideration.
>
> Yours,
> Russ Magee %-)
>
>
> On Mon, Dec 8, 2014 at 11:37 PM, Tim Graham <[email protected]> wrote:
>
>> Hi Rune,
>>
>> It's not clear to me that a fix that's coupled to the admin is the way to
>> go when this problem could exist for any model form, etc.
>>
>> One ticket you didn't mention that seems like it could be a good place to
>> start is https://code.djangoproject.com/ticket/16549
>>
>> Tim
>>
>> On Monday, December 8, 2014 8:04:30 AM UTC-5, Rune Kaagaard wrote:
>>>
>>> @Daniele
>>>
>>> I struggled a bit with how to display the error message, and your
>>> solution makes perfect sense.
>>>
>>> Best,
>>> Rune Kaagaard
>>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django developers (Contributions to Django itself)" 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].
>> Visit this group at http://groups.google.com/group/django-developers.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-developers/f1a56260-89d7-4439-aed1-9407d799f62f%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-developers/f1a56260-89d7-4439-aed1-9407d799f62f%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django developers (Contributions to Django itself)" 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].
> Visit this group at http://groups.google.com/group/django-developers.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-developers/CAJxq84_Kz_6ZCTzxEjaZm61hdfYcKnQNHw-xyPr%3DzX%3Dtc8GYvw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-developers/CAJxq84_Kz_6ZCTzxEjaZm61hdfYcKnQNHw-xyPr%3DzX%3Dtc8GYvw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" 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].
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAODHHFAJct5FCDD8gcrB0_L-yOwXuyMx6PzmeHzHacyHgVhC9w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to