[cgi-wiki-dev] How to write node with versions

Kake L Pugh kake at earth.li
Wed Dec 26 00:05:23 GMT 2007


On Tue 25 Dec 2007, abhishek jain <abhishek.netjain at gmail.com> wrote:
> I am using the code given in Synopsis and using the function directly
>  my $written = $wiki->write_node('Home', 'abhishek struggles for this
> wiki.',undef,{},1 );

It really would be easier to figure out what's going on if you could
send the actual code you're using.  When I asked if you could show us
your code, I meant actually show us the code, as in attach the script
that's giving you problems.  It's easier to show it than to describe it.

Having said that, my guess is that your problem is caused by not
supplying the checksum, since your third argument is undef.  You
should only have undef there if it's the first time you've written the
node.  The point of the checksum is to make certain that you're not
overwriting someone else's changes to the wiki page.

If you check the return value of ->write_node, this should show up - if
the write fails, the return value will be false, whereas if it succeeds
then the return value should be true.

If we didn't use a checksum, this would be possible:

Person A loads up a wiki page and decides to change it, so clicks on
"edit this page" and starts making their changes.
Person B loads up the same wiki page and decides to change it, so clicks on
"edit this page" and starts making their changes.
Person A finishes their edits and clicks "save".
Person B finishes their edits and clicks "save".

The problem here is that Person B has never seen Person A's edits, but
has saved their own edits on top of it - so Person A's edits are lost.

The way the checksum works is that when you ask $wiki for the content of
the page in order to display it in the edit form, it also gives you a
checksum which is unique to that version of that page.  You need to put
this checksum in the edit form as a hidden field, so when the user comes
to save the wiki page content, it's possible to make sure that the version
the user was editing is the same as the current version in the database.

So you want something like this:

my %pagedata = $wiki->retrieve_node( "My Page" );
$wiki->write_node( "My Page", "New stuff on my page", $pagedata{checksum} );

> I was also wondering what does this moderation bit means i mean what is the
> concept of moderation here.

I think it was Nick Burch who wrote the moderation stuff, so I don't
entirely understand it, but the idea is that if a node has its
moderation bit set, then any changes committed to the page will only
show up once an administrator has approved them.  It does have some
bugs though.

> Also what is checksum and its concept related to wiki here.

Explained above.

> I am interested into the project you guys are doing is there a mean by which
> i can also contribute, i mean by writing some code,

There is!  Our release manager is Dominic Hargreaves, and he can tell
you all about that, but I think he's one of these people who celebrate
Christmas so probably won't be checking email today :)

Kake



More information about the CGI-Wiki-dev mailing list