On Monday 04 Feb 2008, Michael Hipp wrote:
> Tim Sawyer wrote:
> > 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?
>
> I'd love to see something like this added.
>
> Can it be done entirely in SQL or does it require some stored triggers
> or rules in the database?

I believe it can be done entirely in SQL.

* Select Object (for example ID, Version, Surname, Forename) - version column 
defaults to 0 for new inserts

* When object is updated, do an UPDATE blah WHERE id = :id and version 
= :version.  If your update updated no rows, raise a locking error

There would also have to be code added into the admin front end to deal with 
locking errors.

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