[Pmwiki-users] Emacs and simultaneous edits
Patrick R. Michaud
pmichaud
Sun Oct 3 22:46:40 CDT 2004
On Mon, Oct 04, 2004 at 03:44:34AM +0200, chr at home.se wrote:
> > > ** The lack of being able to use Emacs/pmwiki-mode is a showstopper here
> > > for efficiency reasons.
> >
> > I'm afraid that one is in your court, as I don't use Emacs :-) .
> > However, the interface is almost entirely the same between v1.0 and
> > v2.0, so you should be able to do basic editing (without simultaneous
> > edit detection/handling) pretty much the same as before.
>
> I just tried to use the existing pmwiki-mode to edit the sandbox (v2), and
> although I can still retrieve the source (?action=source) as before,
> changes are not written properly to the wiki page. The writing is done
> using a http-post operation, but the result seems to be full HTML code for
> a normal page. I can look closer at that if you think it'll contain
> something of interest.
One difference is that PmWiki v2.0 no longer supports ?action=post.
Instead, use ?action=edit and make sure that the "post" control is set
to non-zero (i.e., the same as if you did ?action=edit&post=1) -- this
is what tells PmWiki that the operation is a post operation.
> Do you think it is at all possible for pmwiki-mode to use the same method
> for saving to both v1.0 and v2.0?
Yup, doing "action=edit" with "post=1" works under PmWiki 1.0 also.
> > In order for the editor to participate in simultaneous edit handling, it
> > needs to be able to pass back the timestamp given in the page when
> > ?action=edit was requested, and to see if the post was successful.
>
> I don't actually used ?action=edit, but rather ?action=source... Using
> ?action=edit seems wrong for pmwiki-mode, since I'll get this other stuff
> that I don't really need.
I could have ?action=source return the timestamp in an HTTP header, if
your script has some way to retrieve it. If not, we'll have to find some
way to encode the timestamp in the source, or provide some sort of option
that says how to get the source.
> > (Or, if you trust your clock to match the server's clock closely enough,
> > Emacs/pmwiki-mode could just use the time when the page was retrieved.)
>
> That's not likely to work out of the box.
Oh, differences of a few seconds won't matter. Differences of a minute
or more might.
> However, it seems like the best way for me to start on this is if I can
> understand how it is supposed to work. Could you describe the algorithm
> that's used by v2.0 for simultanoues editing?
Sure. When an author requests ?action=edit, there's a hidden field
called 'basetime' that contains the time at which the page was retrieved.
When the author presses "Save", PmWiki receives the updated text and the
basetime, and checks to see if the page has been modified since the basetime.
If so, it cancels the save, merges the author's changes with the ones
that have occurred since the basetime, and returns an edit form with the
merged changes back to the author (with a new basetime) for review/cleanup.
If text is submitted without a basetime field, PmWiki just accepts the new
text without attempting a merge (i.e., same as PmWiki 1).
Another consideration: PmWiki 2 now defaults to session-based authentication
instead of HTTP Basic authentication, so handling edits of password-protected
pages may be a bit different as well (although we can certainly come up
with mechanisms for handling this relatively easily).
Pm
More information about the pmwiki-users
mailing list