Back to index

moin  1.9.0~rc2
wikirestore.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 """
00003 This script reads a wikibackup.pickle file and puts
00004 all Pages contained there into a wiki via xmlrpc.
00005 We use wiki rpc v2 here.
00006 
00007 Important note:
00008 
00009 This script ONLY handles the current versions of the wiki pages.
00010 
00011 It does NOT handle:
00012     * event or edit logs (page history)
00013     * old versions of pages
00014     * attachments
00015     * user account data
00016     * MoinMoin code or config running the wiki
00017 
00018 So this is definitely NOT a complete restore.
00019 
00020 GPL software, 2003-10-24 Thomas Waldmann
00021 """
00022 def run():
00023     import xmlrpclib
00024     from MoinMoin.support.BasicAuthTransport import BasicAuthTransport
00025     from MoinMoin.util import pickle
00026 
00027     user = "ThomasWaldmann"
00028     password = "xxxxxxxxxxxx"
00029     dsttrans = BasicAuthTransport(user, password)
00030     dstwiki = xmlrpclib.ServerProxy("http://devel.linuxwiki.org/moin--cvs/__xmlrpc/?action=xmlrpc2", transport=dsttrans)
00031     #dstwiki = xmlrpclib.ServerProxy("http://devel.linuxwiki.org/moin--cvs/?action=xmlrpc2")
00032 
00033     backupfile = open("wikibackup.pickle", "r")
00034     backup = pickle.load(backupfile)
00035     backupfile.close()
00036 
00037     for pagename in backup:
00038         pagedata = backup[pagename]
00039         dstwiki.putPage(pagename, pagedata) # TODO: add error check
00040         print "Put %s." % pagename
00041 
00042 if __name__ == "__main__":
00043     run()
00044