Don't do this.
There is no way to make 100% certain that you don't end up with stale
locks. Sure, you can have an ajaxy thing that pings the server every
minute or so to say, "I'm still editing this", but then the user goes
off to lunch and everyone is stuck until they get home. Or a malicious
user can lock up all your pages forever.
If you do do it, make sure your locks are merely advisory ("Warning:
Karl is editing this page right now."). If your data is simple enough,
allow both edits and then merge changes programatically and let the user
resolve conflicts (like svn). If it's too complex for that, then just
show the diff and let the user merge the changes.
On Thu, 2007-09-06 at 13:07 -0700, Jose Galvez wrote:
> Hi all, I'm hunting for advice. I am looking for a way to "lock" a
> webpage so that only only one person at a time can edit database data.
> Here is the scenario, I have a database with a limited number of users
> who have write access to the database, what I'd like to do is lock the
> editing page so that if one of my users is editing a page then the
> other users will not be able to edit the same page(data) at the same
> time. I know that this is what transactions are for in a database,
> but what I want to avoid is two people looking at the same unedited
> data and then editing it. I guess what I really want to is lock a
> database when I use starts editing the data. The issues are:
> 1) How to make sure someone exits the edit mode nicely? what happens
> if they enter the edit page, do nothing and just close the browser, I
> don't what to leave the table locked
> 2) if the table is locked I would still like to let users view the
> data in real time, jut not edit it.
>
> I've used a "lock" table for this in the past, but the issue that I've
> never figured out is how to make sure someone still needs the lock.
> Again number (1) from above.
>
> I hope that this makes sense, I'll be using sqlalchemy and postgres on
> the back end
>
> thanks for any and all advice
> jose
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" 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/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---