view MoinMoin/scripts/xmlrpc-tools/ @ 0:77665d8e2254

tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0 (automatically generated log message) imported from: moin--main--1.5--base-0
author Thomas Waldmann <>
date Thu, 22 Sep 2005 15:09:50 +0000
children be33ecd58d4e
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))

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'])