Discussion:
Generate and Modify Pages with python
kent sin
2005-02-18 16:24:06 UTC
Permalink
I just install 1.3.3 and find out that pages structure
is more complicate then before.

In old days, I can just place text files in directory
and moinmoin will recognize it just like apache do.

Now, there is a whole directory of various things.

I try to follow the MoinDev/Storage and try a

from MoinMoin.Page import Page

page = Page("NewPage")

but it fails.

How can I Generate or Modify Moin Pages with cron
jobs? Shall I have to do this through the web? or I
can do it with Python? Will the future change again?

Best Rgs,

Kent Sin


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
Thomas Waldmann
2005-02-18 17:12:39 UTC
Permalink
Hi kent,
Post by kent sin
I just install 1.3.3 and find out that pages structure
is more complicate then before.
Yes, that change was necessary to get rid of that "mtime mess".
Post by kent sin
I try to follow the MoinDev/Storage and try a
from MoinMoin.Page import Page
page = Page("NewPage")
but it fails.
You need to use PageEditor / _write_file if you do it that way.

Or look into the standardized(!) xmlrpc interface (see
MoinMoin/scripts/xmlrpc/... - very easy to use from python scripts,
maybe from other languages with xmlrpc lib, too).

Be aware that you have to enable that by modifying the wikirpc.py file.

As xmlrpc is a standard (and xmlrpc2 is an almost-standard), it is
unlikely that that stuff changes.

BTW: better choose wiki xmlrpc v2, much better to use than wiki xmlrpc v1.
Post by kent sin
Will the future change again?
Yes, we will further enhance the storage stuff for making moin more
versatile and powerful, while making the code simpler and more structured.

1.4devel already uses generic "mimetype items", not pages. Metadata is
stored separately. The code handling that will be object oriented and
exploiting inheritance.

Maybe we will even switch to have a directory with a collection of files
*per revision*, so we can store multi-file data as twikidraw creates it
(drawing.draw, drawing.map, drawing.png). Of course this would be the
most generic solution, but it costs 1 additional directory per item
revision (and often it will contain only 2 files).

We know that those structures are of course more complicated to handle
by shell scripts than in <=1.2.x, but we try to keep that possibility by
using some easy text based data formats.

Thomas


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
Nir Soffer
2005-02-19 08:23:34 UTC
Permalink
Post by kent sin
I just install 1.3.3 and find out that pages structure
is more complicate then before.
In old days, I can just place text files in directory
and moinmoin will recognize it just like apache do.
Now, there is a whole directory of various things.
The structure is not really more complicated, but more structured. The
old way used to put one page data in multiple directories. For example,
in the old structure it was almost impossible to remove a page, or to
get the first revision of a page.

The page structure is quite simple now:

PageName - the directory name is the page name
edit-log - the page private log of changes
current - this file contain the name of the current revision, e.g
00000001. If there is no such revision, the page is considered deleted
page.
revisions/ - the directory containing the revisions
00000001 - the first revision
attachments - the directory containing the page attachments, if
there are any attachments
cache/ - automatically created by the wiki, contain page caches

So you can see that its quite easy to add a page with a shell script:

cd /www/MyWiki/data/pages
mkdir PageName
echo 00000001 > PageName/current
mkdir PageName/revisions
echo "That was quite easy!\n" > PageName/revisions/00000001

Or to remove a page from the system - including all backups,
attachments:

rm -rf PageName

Or to rename a page:

mv PageName NewName

Try to do that with 1.2 - don't forget to rename all backups,
attachments and the logs...

Or move a page to another wiki instance:

mv WikiA/data/pages/PageName WikiB/data/pages/
Post by kent sin
I try to follow the MoinDev/Storage and try a
from MoinMoin.Page import Page
page = Page("NewPage")
The wiki pages are outdated. You will have to read the code if you want
to write python. Pages and many other functions have a request object
as first argument. Its little harder now to create pages, but its not
related to the new structure. The best way is to see how this is done
in other code.


Best Regards,

Nir Soffer



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click

Continue reading on narkive:
Loading...