view MoinMoin/scripts/xmlrpc-tools/ @ 491:be33ecd58d4e

add run() methods to scripts, include version info into MoinMoin/ for epydoc imported from: moin--main--1.5--patch-495
author Thomas Waldmann <>
date Wed, 22 Mar 2006 09:55:32 +0000
parents 77665d8e2254
line wrap: on
line source
#!/usr/bin/env python
This script is a hack because moinmaster wiki does not support
xmlrpc due to unknown reasons. It gets all SystemPages from srcwiki
via action=raw and stores them into dstwiki via xmlrpc.

We use wiki rpc v2 here.

GPL software, 2003-09-27 Thomas Waldmann

import xmlrpclib, urllib
from MoinMoin import wikiutil
from import BasicAuthTransport

srcurlformat = ""
user = "YourWikiName"
password = "yourbasicauthpassword"
srcwiki = xmlrpclib.ServerProxy("")
dsttrans = BasicAuthTransport(user,password)
dstwiki = xmlrpclib.ServerProxy("", transport=dsttrans)

def rawGetPage(srcurl, pagename, encoding='iso-8859-1'):
    url = srcurl % wikiutil.quoteWikinameFS(pagename.encode(encoding))
    pagedata = urllib.urlopen(url).read()
    return unicode(pagedata, encoding).encode('utf-8')

def transferpage(srcurlformat, dstwiki, pagename):
    pagedata = srcwiki.getPage(pagename)
    #pagedata = rawGetPage(srcurlformat, pagename, 'iso-8859-1')
    rc = dstwiki.putPage(pagename, pagedata)
    print "Transferred %s. Len = %d, rc = %s" % (pagename.encode('ascii','replace'), len(pagedata), str(rc))

def run():
    allsystempagesgroup = 'AllSystemPagesGroup'
    transferpage(srcurlformat, dstwiki, allsystempagesgroup)
    allgrouppages = dstwiki.listLinks(allsystempagesgroup)

    for langgrouppage in allgrouppages:
        pagename = langgrouppage['name']
        transferpage(srcurlformat, dstwiki, pagename)
        pages = dstwiki.listLinks(pagename)
        for page in pages:
            transferpage(srcurlformat, dstwiki, page['name'])

if __name__ == "__main__":