This question about Developing extensions (plugins skins etc.): Asked

Posting to wiki through python script

-- BenFireshark - 21 May 2013

I have tried 6 or 7 completely different angles, this one being the latest. I have little to no experience interacting with web pages through python, so most of this is guess work. I have no trouble reading the pages, but trying to edit the topic is another matter. The pages require user authentication as well.

import httplib2

h = httplib2.Http(".cache")

h.add_credentials('Username', 'Password') resp, content = h.request("http://wiki.com/Sandbox/BenFiresharkSandbox",

"PUT", body="This is text",

headers={'content-type':'text/plain'} )

-- BenFireshark - 21 May 2013
 

Hello all,

I'm currently stuck on a project that I cannot find the answer to around the interwebs.

I am attempting to overwrite/update topics on the wiki with data from a csv on my local

machine using a python script, but I am having trouble getting anything to come through.

I assume there is a procedure that I should follow for this to work but I'm stuck. Any

help is appreciated!


If you paste your script here we might be able to help. It's probably to do with the parameters you are passing to the Foswiki scripts.

-- CrawfordCurrie - 21 May 2013

Foswiki supports a number of different ways of passing user authentication, depending on what your setup is. What you have done above is appropriate is you are using BasicAuth with ApacheLoginManager. If you are using TemplateLoginManager (the default) you need to pass username= and password= URL parameters (or, if you are using the as-yet-unreleased 1.2.0, you can use an X-Authorization header with the authentication domain FoswikiBasic).

it looks like you may be using URL rewriting to access the "view" script (http://wiki.com/Sandbox/BenFiresharkSandbox is probably rewritten to http://wiki.com/bin/view/Sandbox/BenFiresharkSandbox) in which case a PUT to this script isn't going to work. You need to be sending to the save script (and you should be using a POST, not a PUT). You need to read CommandAndCGIScripts carefully to make sure you are passing the correct parameters.

To understand what is going on it is extremely helpful to look at the Apache log files on the server (if you have access).

If you want to access the wiki as if it was a web folder, you can use WebDAV (google it) - I offer a WebDAV connector for sale.

-- CrawfordCurrie - 22 May 2013

QuestionForm edit

Subject Developing extensions (plugins skins etc.)
Extension
Version Foswiki 1.1.3
Status Asked
Related Topics
Topic revision: r4 - 22 May 2013, CrawfordCurrie
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy