view MoinMoin/scripts/xmlrpc-tools/wikirestore.py @ 491:be33ecd58d4e

add run() methods to scripts, include version info into MoinMoin/__init__.py for epydoc imported from: moin--main--1.5--patch-495
author Thomas Waldmann <tw@waldmann-edv.de>
date Wed, 22 Mar 2006 09:55:32 +0000
parents 77665d8e2254
children
line wrap: on
line source
#!/usr/bin/env python
"""
This script reads a wikibackup.pickle file and puts
all Pages contained there into a wiki via xmlrpc.
We use wiki rpc v2 here.

Important note:

This script ONLY handles the current versions of the wiki pages.

It does NOT handle:
    * event or edit logs (page history)
    * old versions of pages
    * attachments
    * user account data
    * MoinMoin code or config running the wiki
    
So this is definitely NOT a complete restore.

GPL software, 2003-10-24 Thomas Waldmann
"""
def run():
    import xmlrpclib
    from MoinMoin.support.BasicAuthTransport import BasicAuthTransport

    user = "ThomasWaldmann"
    password = "xxxxxxxxxxxx"
    dsttrans = BasicAuthTransport(user,password)
    dstwiki = xmlrpclib.ServerProxy("http://devel.linuxwiki.org/moin--cvs/__xmlrpc/?action=xmlrpc2", transport=dsttrans)
    #dstwiki = xmlrpclib.ServerProxy("http://devel.linuxwiki.org/moin--cvs/?action=xmlrpc2")

    try:
        import cPickle as pickle
    except ImportError:
        import pickle

    backupfile = open("wikibackup.pickle","r")
    backup = pickle.load(backupfile)
    backupfile.close()

    allpages = backup.keys()
    for pagename in allpages:
        pagedata = backup[pagename]
        dstwiki.putPage(pagename, pagedata) # TODO: add error check
        print "Put %s." % pagename

if __name__ == "__main__":
    run()