[Pmwiki-users] Edit / Lock Pages

Christian Ridderström chr
Tue Jan 27 13:30:20 CST 2004


On Tue, 27 Jan 2004, Jonathan Scott Duff wrote:

> On Tue, Jan 27, 2004 at 05:40:48PM -0800, Steven Leite wrote:
> > Re: Edit / Lock Pages
> >
> > I noticed a recurring question (while reading the mailing list
> > archives from as far back as 2002) which is:
> >
> > What if more than one person tries to edit a page at one time?
> >
> > Answer: Just have a flag on the page that says it's being edited. When
> > you click the EDIT button, it gets turned ON, and when you click SAVE
> > the flag is turned OFF.

I think we need more than a binary flag. Here's one solution that's used 
by MoinMoin IIRC.

* The edit page/form get's a hidden field with the lastest time the page's 
  file was modified (mtime).

* When the new page source is submitted, the stored mtime is compared 
  to the current mtime

** If the mtimes are identical, it's safe to write the changes.
   If the current modification time has increased, someone else has 
   modified the page and you may have a conflict.

Note: A file lock is probably needed just before writing the changes, i.e. 
to make sure that someone else doesn't manage to write in the small amount 
of time between getting the mtime and starting to write :-)

/Christian

-- 
Dr. Christian Ridderstr?m, +46-8-768 39 44       http://www.md.kth.se/~chr




More information about the pmwiki-users mailing list