Is there any "standard" or "best practice" way of handling concurrent
editing of data in tg2?  I am referring not to "machine-scale"
concurrency, which is nicely handled by database transactions, but
rather "human-scale" concurrency -- such as in a CRUD application,
when two users have a record open at the same time, and each makes
changes.  This is the classic "lost update" problem:

1. User A loads the record and starts editing it.
2. User B loads the record and starts editing it, before A saves his
changes.
3. User A saves his changes.
4. User B saves his changes, overwriting user A's changes.

Database transactions don't help you here unless you keep the
transaction open during the user's entire session, not just during a
request -- which is almost always a bad idea.  The typical modern way
of dealing with this on the web -- if you deal with it at all -- is
opportunistic locking, where before you save changes you check to see
if any updates were made since the data was originally presented to
the user.  This usually means having a timestamp and/or incrementing
version column in each database table, which is sent along with the
data in a hidden form field (or JSON data structure), and sent back on
submit.  If at that point the timestamp or version number has changed,
you either (a) try to merge the changes, if possible, or (b) inform
user B that they were editing a stale copy of the data, and make them
start over or give them a way to merge the versions themselves.

So my question is -- is any of this pre-built for me in TG2?  Does
Catwalk or tgext.crud.controller handle this, or if I use the stock
Catwalk to edit my databases, am I vulnerable to the lost update
problem?  Anybody have some recipes for hooking these kinds of checks
in at a low level, so I don't have to repeat the version handling code
everywhere?

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

Reply via email to