Description

xmlrpc putPage stores unchanged pages into new revisions

Steps to reproduce

You need to enable xmlrpc in your wikiconfig(_local).py and set up a user with write access to the wiki. The name and password has to be replaced in the script

   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()

test_case2.py

Component selection

Details

this wiki

Workaround

Don't add an empty line at the bottom. e.g. text = ['bla','blub']

Discussion

The problem is caused from the extra empty line at the bottom text = ['#format %s\n' % markup] + text + ['\n'] This extra line is dropped by saving to the page but it is used for comparing the input.

This is something between a feature and a bug. PageEditor.saveText checks the content of an existing page by comparison of the new content. If it is different it becomes a new revision. If you add to a new revision an empty line by e.g. xmlrpc putPage then this line is removed during the save process after the comparison found that both pages are different. That ways you store the same content twice. It looks to me currently that some of the pages changed by the gui editor have the same problem.

Plan


CategoryMoinMoinBug

MoinMoin: MoinMoinBugs/XmlrpcPutPageStoresUnchangedPages (last edited 2009-12-08 19:04:11 by ReimarBauer)