Remoting support in MoinMoin using Wiki XML-RPC
While I've setup MoinMoin as a PIM and notes organizer for over a year. I found that it is not really convenient. Mostly because I am used to write notes in Vi but not in the browser. As a result I started to look for some remoting support in MoinMoin which can enable me editing notes in whatever editor I like. After some goolging and a little bit coding, I finally come-up with a satisfactory solution. This page is mainly a log of my effort, findings and a handy script.
Some background
- XML-RPC
Simple remoting mechanism developed on XML and HTTP. Specification can be found here.
- Wiki XML-RPC
Wiki XML-RPC interface. Reference for the interface is http://jspwiki.org/wiki/WikiRPCInterface2 here].
Wiki XML-RPC Support in MoinMoin
MoinMoin support for Wiki XML-RPC can be summaried as below:
- Support Wiki XML-RPC v2
MoinMoin has XML-RPC plugin architecture, new XML-RPC action can be developed using this extension point. (called xmlrpc plugin)
MoinMoin have some XML-RPC based script, not comprehensive enough but it is a good starting point.
More information can be found here.
Supporting Authentication
Wiki XML-RPC does not address authentication issue clearly, but MoinMoin allow HTTP Auth
Not all MoinMoin supported installation type impl HTTP Auth
- I use twisted (originaly, I use standalone, which DOES NOT support HTTP AUTH)
- Some installation type may also work, as long as it support HTTP Auth
- You need to declare hybrid auth method in wikiconfig.py
import MoinMoin.auth as authmodule
class Config(DefaultConfig):
[...]
auth = [authmodule.http, authmodule.moin_cookie]
[...]In the script, which connect to MoinMoin with XML-RPC, add HTTP auth transport to instantiate the stub
username = "YourUserName"
password = "YourPassword"
wikiaddr = "http://www.nixstyle.net/moin/?action=xmlrpc2"
import sys, xmlrpclib
from MoinMoin.support.BasicAuthTransport import BasicAuthTransport
authtran = BasicAuthTransport(user, password)
srcwiki = xmlrpclib.ServerProxy(wikiaddr, transport=authtran)
Know issue about the putPage action
You need to turn on a configuration item, otherwise, when XML-RPC putPage action invoked, the page will always saved as 'PutPageTestPage'.
xmlrpc_putpage_enabled = True
- There is another minor issue regarding the putPage action. When putPage finish a exception is throw, because the request object does not have the formatter object defined.
The bug is triggerred during the edit-log writing. I've add two line patch to MoinMoin wikirpc.py to workaround this issue. Note that, I have no idea if the patch is sane or not. You can choose to ignore it. Your page will still be saved properly, you just found that there is an exception everything you save a page. The patch is attached here.
Sure, don't forget to restart MoinMoin
Extending MoinMoin XML-RPC to support extra operation
Use [remoteMoin http://labix.org/editmoin], which is a set of MoinMoin xmlrpc plugin
- Download and extract the tarball, put all .py into your instance plugins dir
cp *.py [your_wiki_instance]/data/plugin/xmlrpc/
Restart MoinMoin
My Script to support my remoting needs
The final step is to implement a script on top of the XML-RPC stub to support basic command like 'list', 'read', 'edit', and 'rename'.
The script is initially based on editmoin.
The script can be download from here (GPL).
Note that, you need to fill-in your username / password and the wiki URL in the script.