Attachment 'test_case2.py'

Download

   1 #!/usr/bin/env python
   2 # -*- coding: iso-8859-1 -*-
   3 
   4 """
   5 Just examples for using the xmlrpc calls.
   6 
   7 """
   8 import getpass
   9 import os
  10 import time
  11 import xmlrpclib
  12 
  13 NAME = os.environ.get("WIKIUSER", "")
  14 PAGENAME = u"ExampleTestPage"
  15 ATTACHNAME = u":example.png"
  16 PASSWORD = getpass.getpass()
  17 WIKIURL = "http://localhost:8080/"
  18 
  19 def put_page():
  20     """"
  21     this script creates a page PAGENAME
  22     """
  23     if NAME and PASSWORD:
  24         xmlrpc_url = "%s?action=xmlrpc2" % WIKIURL
  25         homewiki = xmlrpclib.ServerProxy(xmlrpc_url, allow_none=True)
  26         multicall = xmlrpclib.MultiCall(homewiki)
  27         auth_token = homewiki.getAuthToken(NAME, PASSWORD)
  28         if auth_token:
  29             multicall.applyAuthToken(auth_token)
  30             text = ['bla','blub','\n']
  31             multicall.putPage(PAGENAME, '\n'.join(text))
  32             result = multicall()
  33             try:
  34                  msg, result = tuple(result)
  35             except:
  36                  msg, result = ('Error', 
  37                 "page '%s': You did not change the page content, not saved!" % PAGENAME)
  38             print result
  39 
  40 if __name__ == "__main__":
  41     put_page()

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2009-12-08 19:02:26, 1.1 KB) [[attachment:test_case2.py]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.