comparison MoinMoin/scripts/xmlrpc-tools/getmasterpages2.py @ 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 <tw-public@gmx.de>
date Thu, 22 Sep 2005 15:09:50 +0000
parents
children be33ecd58d4e
comparison
equal deleted inserted replaced
-1:000000000000 0:77665d8e2254
1 #!/usr/bin/env python
2 """
3 This script is a hack because moinmaster wiki does not support
4 xmlrpc due to unknown reasons. It gets all SystemPages from srcwiki
5 via action=raw and stores them into dstwiki via xmlrpc.
6
7 We use wiki rpc v2 here.
8
9 GPL software, 2003-09-27 Thomas Waldmann
10 """
11
12 import xmlrpclib, urllib
13 from MoinMoin import wikiutil
14 from MoinMoin.support.BasicAuthTransport import BasicAuthTransport
15
16 srcurlformat = "http://moinmaster.wikiwikiweb.de/%s?action=raw"
17 user = "YourWikiName"
18 password = "yourbasicauthpassword"
19 srcwiki = xmlrpclib.ServerProxy("http://moinmaster.wikiwikiweb.de/?action=xmlrpc2")
20 dsttrans = BasicAuthTransport(user,password)
21 dstwiki = xmlrpclib.ServerProxy("http://devel.linuxwiki.org/moin--main/__xmlrpc/?action=xmlrpc2", transport=dsttrans)
22
23 def rawGetPage(srcurl, pagename, encoding='iso-8859-1'):
24 url = srcurl % wikiutil.quoteWikinameFS(pagename.encode(encoding))
25 pagedata = urllib.urlopen(url).read()
26 return unicode(pagedata, encoding).encode('utf-8')
27
28 def transferpage(srcurlformat, dstwiki, pagename):
29 pagedata = srcwiki.getPage(pagename)
30 #pagedata = rawGetPage(srcurlformat, pagename, 'iso-8859-1')
31 rc = dstwiki.putPage(pagename, pagedata)
32 print "Transferred %s. Len = %d, rc = %s" % (pagename.encode('ascii','replace'), len(pagedata), str(rc))
33
34 allsystempagesgroup = 'AllSystemPagesGroup'
35 transferpage(srcurlformat, dstwiki, allsystempagesgroup)
36 allgrouppages = dstwiki.listLinks(allsystempagesgroup)
37
38 for langgrouppage in allgrouppages:
39 pagename = langgrouppage['name']
40 transferpage(srcurlformat, dstwiki, pagename)
41 pages = dstwiki.listLinks(pagename)
42 for page in pages:
43 transferpage(srcurlformat, dstwiki, page['name'])
44