MoinMoin Filesystem storage (moin 1.5 .. 1.9.x)

Logs

Edit log

There are 2 edit logs: a global one (per wiki) and a local one (per page):

The edit log is a flat file format that records all editing. Page saves, attachment creation and deletion are all recorded. The following data is saved per edit :

The modified time is UTC microseconds. The 'extra' field is usually empty and contains the old name the page in the case of a rename edit

In the case of an attachment edit :

The different types of edit are :

MoinMoin/logfile/editlog.py handles management of the edit logging.

Event log

The event log is a flat file list which stores HTTP queries to the wiki. It is stored in wikiname/data/event-log. Information stored is:

The time of access is UTC, or GMT time, the same as is returned by the Python standard time module.

Request type will be one of :

The request information contains relevant information for the request type in the form:

Attributes are:

MoinMoin.logfile.eventlog handles the event log.

Error log

The error log is a flat file storing error and warning messages from the system. It is stored in wikiname/data/error.log. This file stores python tracebacks from page errors and deprecation warning messages.

/!\ This error.log existed in some ancient moin version, but does not exist any more in moin 1.9.x - by default moin emits log output on stderr (which should either end up on your console or in the webserver's error.log). If you want it somewhere else, you need to configure logging, see moin.wsgi (or whatever adapter file you use).

Pages

All information associated with wiki pages is stored in the data/pages/ directory. Each page is stored as a separate subdirectory, containing the following elements:

current
This file contains a single number, which is the name of the current revision, e.g. 00000001. If there is no such revision number, the page is considered deleted.
edit-log

the local edit-log of this page. Some log entries get logged into the global edit-log for all pages. This file contains lines with the following tab-separated values: edit time (microseconds since 1970-01-01T00:00), revision number, edit type, page name, remote IP address, remote hostname, user id, comment.

revisions (directory)

Stores the current and past versions of the page, exactly as they appear in the edit window in text format. Each page revision is stored in a file named, e.g., 00000001. The current page revision is the one pointed to by the current marker file.

cache (directory)
Internal caching information for system optimizations. If this direcory is not present, it will be created the first time a page is accessed.
attachments (directory)
stores attachments for the page, if any.

MoinMoin/Page.py handles reading and access of wiki pages in Moin. The MoinMoin.Page.Page class can be used to create a read-only page for programatic use, e.g., to load the front page of your wiki :-

from MoinMoin.request import RequestCLI
from MoinMoin.Page import Page

pagename = 'PageName'
request = RequestCLI('localhost/mywiki', pagename)
page = Page(request, pagename)

Editing pages programatically

Editing of pages is managed through MoinMoin/PageEditor.py and the MoinMoin.PageEditor.PageEditor class.

You can use the PageEditor.saveText(text, revision) function to programatically create or edit (save) pages. For example:

# This code is equivalent to editing a page with a browser and
# replacing the content with 'New text...'. The old revision is saved
# and the edit is logged in the edit-log.

from MoinMoin.PageEditor import PageEditor
from MoinMoin.request import request_cli

pagename = 'PageName'
request = request_cli('localhost/mywiki', pagename)
# if your page has ACLs, you may need to simulate a user - replace 'someuser' as appropriate
# from MoinMoin import user
# request.user = user.User(request, auth_username='someuser')
editor = PageEditor(request, pagename)
text = editor.normalizeText('New text...')
dummy, revision, exists = editor.get_rev()
return editor.saveText(text, revision)

MoinMoin.request doesn't exist anymore in the latest version. The new equivalent code would be:

# This code is equivalent to editing a page with a browser and
# replacing the content with 'New text...'. The old revision is saved
# and the edit is logged in the edit-log.

from MoinMoin.PageEditor import PageEditor
from MoinMoin.web.contexts import ScriptContext

pagename = 'PageName'
request = ScriptContext('localhost/mywiki', pagename)
# if your page has ACLs, you may need to simulate a user - replace 'someuser' as appropriate
# from MoinMoin import user
# request.user = user.User(request, auth_username='someuser')
editor = PageEditor(request, pagename)
text = editor.normalizeText('New text...')
dummy, revision, exists = editor.get_rev()
return editor.saveText(text, revision)

See also ScriptMarket/AppendTextScript or MoinAPI/Examples.

Editing pages from the shell

An alternative for creating new pages is to do so directly, for example from the unix shell.

/!\ Warning - using this method bypasses the wiki security, access controls, and revision history. Use with caution.

cd ~/mywiki/data/pages/
mkdir TestPage
mkdir TestPage/revisions
echo "= Saving page from the shell =\nIs easy :)" > TestPage/revisions/00000001
echo 00000001 > TestPage/current

Or to remove a page entirely:

cd ~/mywiki/data/pages/
rm -r TestPage

Attachments / Drawings

Attachments and Drawings are in flat files, too, and their storage code is not factored out either (see AttachFile.py, Page.py). Some (external) extensions may create attachments.

Storage of attachments in moin 1.5 is like this: data/pages/PageName/attachments/filename_in_utf8_encoding.txt

As you see, there is NO revisioning for attachments.

User Profiles

The user profiles are stored under data/user/.

Moin 1.5.x:

Moin 1.6:

Note about drawings in moin 1.9.x:

Caching

Caching is used when we need fast access to some data. It is always non-authoritative and easily rebuilt; its absence causes no problems.

When creating a cache, you can give a scope, which determines its storage location, e.g., local in the page directory, in the wiki directory, or in a common farm cache.

The caching module uses the filesystem to store its cache contents.

MoinMoin: MoinDev/Storage (last edited 2013-05-25 19:15:44 by HSI-KBW-078-042-160-036)