Welcome, guest | Sign In | My Account | Store | Cart

Moves all wiki pages from one Firefly (Trac) project to another (optionally deleting all wiki pages in the target project first).

The full xml-rpc API can be found in every Firefly project. For example: http://firefly.activestate.com/troyt/sandbox/xmlrpc

Python, 21 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env python

import xmlrpclib

# replace the usernames, passwords, and project URLs with real ones

project1 = xmlrpclib.ServerProxy("http://username:password@firefly.activestate.com/username/project1/login/xmlrpc")
project2 = xmlrpclib.ServerProxy("http://username:password@firefly.activestate.com/username/project2/login/xmlrpc")

# wiki.putPage() throw errors and quits when it tries to overwrite an
# existing wiki page. Uncomment this section to delete all pages in
# project2 first

#pagenames_project2 = project2.wiki.getAllPages()
#for name in pagenames_project2:
#    project2.wiki.deletePage(name)

pagenames_project1 = project1.wiki.getAllPages()
for name in pagenames_project1:
    page_contents = project1.wiki.getPage(name)
    project2.wiki.putPage(name, page_contents, {"comment": "Copying wiki pages"})

The use of getAllPages() is a bit obtuse, as you probably don't want to copy over all the "default" wiki pages. Using wiki.getRecentChanges() would probably be better for most people.