On Sunday 03 Feb 2008, code_berzerker wrote:
> How about rewriting save method complately and make additional
> condition in WHERE clausule like this:
> UPDATE ....... WHERE id=666 AND mtime=object_mtime
> Checking number of updated rows would give you information about
> success and would guarantee that there is no data manipulation between
> mtime check and save.

If you're going to do that, then couldn't we change the framework to add a new 
VersionField.  If there is a VersionField defined on the object, then the 
code on save could automatically be added.  This VersionField would simply 
hold a version number for the record, that is incremented at save.  This is a 
similar idea to the date thing, but slightly more robust - in a high traffic 
environment there is a theoretical (albeit small) possibility of two objects 
picking up the same time.

This is how hibernate recommends that you do it.  I saw someone suggesting 
this method on this mailing list (found it with a web search I did when I 
first started looking at django), this sounds like the optimum solution for 
optimistic locking to me, and it would open up more use cases for django, at 
least for me.

Would this be straightforward to add?

Tim.



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to