MoinMoin Filesystem storage (moin 1.5 .. 1.9.x)
There are 2 edit logs: a global one (per wiki) and a local one (per page):
The global edit-log is stored in data/edit-log.
The local edit-log is stored in data/pages/PageName/edit-log.
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 :
Moin user id
Description of 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 name of the attachment file is the description of the edit , otherwise it is the comment entered by the user.
- Page revision number is set to 99999999, otherwise it is the current page revision number (more on this later).
The different types of edit are :
SAVENEW - A page was created and committed.
SAVE - A page was edited and committed.
SAVE/RENAME - A page was renamed.
SAVE/REVERT - A page was reverted to a previous revision.
ATTNEW - A new attachment was linked to the page.
ATTDEL - An attachment was deleted from a page.
MoinMoin/logfile/editlog.py handles management of the edit logging.
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:
Time of access
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 :
VIEWPAGE - Show a wiki page.
SAVEPAGE - Save an edited wiki page.
The request information contains relevant information for the request type in the form:
pagename - The name of the page requested or being saved.
REMOTE_ADDR - The IP of the editing machine.
HTTP_USER_AGENT - The name and version number the requesting browser.
HTTP_REFERER - Where the page request comes from.
MoinMoin.logfile.eventlog handles the event 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).
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:
- 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.
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)
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.
The user profiles are stored under data/user/.
- xxxxx.xx.xxxxx (same as userid) file with profile settings
- xxxxx.xx.xxxxx.trail - last few visited pages, used for trail display theme output
- xxxxx.xx.xxxxx (same as userid) file with profile settings and bookmarks
- the trail is stored not in user_dir, but in user's session data.
Note about drawings in moin 1.9.x:
we store foo.tdraw and bar.adraw, those are tar-archives of multiple files that were stored separately in moin < 1.9
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.