~ubuntu-branches/ubuntu/natty/moin/natty-updates

« back to all changes in this revision

Viewing changes to MoinMoin/script/old/xmlrpc-tools/putPageTest.py

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2008-06-22 21:17:13 UTC
  • mfrom: (0.9.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080622211713-fpo2zrq3s5dfecxg
Tags: 1.7.0-3
Simplify /etc/moin/wikilist format: "USER URL" (drop unneeded middle
CONFIG_DIR that was wrongly advertised as DATA_DIR).  Make
moin-mass-migrate handle both formats and warn about deprecation of
the old one.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python
2
 
# -*- coding: utf-8 -*-
3
 
"""
4
 
This script is just an example how to put data into a wiki using xmlrpc.
5
 
We use wiki rpc v2 here.
6
 
 
7
 
This script only works if you edited MoinMoin/wikirpc.py (see the comment
8
 
in the putPage handler) to not require http auth (trusted user) and to
9
 
really use the pagename we give.
10
 
 
11
 
This can be done for migrating data into an offline moin wiki running on
12
 
localhost - don't put a wiki configured like this on the internet!
13
 
 
14
 
GPL software, 2005 Thomas Waldmann
15
 
"""
16
 
def run():
17
 
    import xmlrpclib
18
 
    mywiki = xmlrpclib.ServerProxy("http://localhost/mywiki/?action=xmlrpc2")
19
 
 
20
 
    # first a simple test in pure ascii
21
 
    pagename = "ApureAsciiPage"
22
 
    pagedata = "My first test."
23
 
    mywiki.putPage(pagename, pagedata)
24
 
 
25
 
    # now let's use some utf-8 encoded pagename and text
26
 
    # this stuff will only look correct if you use utf-8 enabled equipment.
27
 
    pagename = "SomeUtf8Pagename-äöüÄÖÜߢ" # we use some german chars here
28
 
    pagedata = "Some UTF-8 content: äöü ÄÖÜ ß ¢"
29
 
    mywiki.putPage(pagename, pagedata)
30
 
 
31
 
    # if you have data in iso-8859-1 (latin1) encoding, then use code similar to:
32
 
    # pagename = latin1pagename.decode('iso-8859-1').encode('utf-8')
33
 
    # pagedata = latin1pagedata.decode('iso-8859-1').encode('utf-8')
34
 
    # mywiki.putPage(pagename, pagedata)
35
 
 
36
 
if __name__ == "__main__":
37
 
    run()
38