>They way I would enivsage adding this functionality to Django would be
>that in your model you specify, for each Model object (=table), that it
>is to be versioned. Versioning would automatically add a '_version'
>column to the generated DDL, and the standard Django save() routines
>would take care of atomically checking and incrementing the row-version
>and throwing exceptions if updates fail because of concurrent changes.

Another appraoch is not to change the Schema at all. Unneccessary and
unrelated fields in the Schema is messy. Instead you can use
'Optimisitic Locking'. All you need to do to perform optimistic locking
is add every column you are changing to the where with the old value.
The only requirement is to keep the old value. A version might save on
memory somewhat, but optimistic locking has he advantage of not needing
to alter the schema.

So if you load a model up e.g

Model.ID = 123
Model.Field1 = 'ABC'

and then you change it:

Model.Field1 = 'DEF'
Model.OldValues['Field1'] = 'ABC'

When you save the object you add the old value to the where clause

update model.tablename set Field1 = 'DEF' where ID = 123 and Field1 =
'ABC';

This achieves the same effect as a version. An exception can be thrown
if the update fails, or handled in any number of ways.


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to