Giter VIP home page Giter VIP logo

dokuwikixmlrpc's Introduction

https://img.shields.io/pypi/dm/dokuwikixmlrpc https://img.shields.io/pypi/v/dokuwikixmlrpc https://img.shields.io/pypi/pyversions/dokuwikixmlrpc https://img.shields.io/pypi/format/dokuwikixmlrpc https://img.shields.io/pypi/l/dokuwikixmlrpc https://img.shields.io/github/stars/kynan/dokuwikixmlrpc?style=social https://img.shields.io/github/forks/kynan/dokuwikixmlrpc?style=social

dokuwikixmlrpc is a python module which implements DokuWiki's XML-RPC interface.

Installation:

pip install dokuwikixmlrpc

It can be used to send/retrieve data from remote DokuWiki instances:

import dokuwikixmlrpc
dw = DokuWikiClient('https://mywikiurl.com', 'wikiuser', 'wikipassword')
print(dw.dokuwiki_version)
print(dw.pagelist(':'))

The module can be executed as a standalone script (this is mainly for testing purposes). Call

python -m dokuwikixmlrpc --help

for more information.

Copyright 2009 by Michael Klier <[email protected]>.

See LICENSE.txt for license info.

dokuwikixmlrpc's People

Contributors

chang-zhao avatar foosel avatar kaie avatar kynan avatar meteopascal avatar oschwab avatar yvesf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

dokuwikixmlrpc's Issues

Basic auth case doesn't add the script path.

This looks wrong to me:

    if not self._http_basic_auth:
        url = ''.join([self._url, script, '?',
                       urlencode({'u': self._user, 'p': self._passwd})])
    else:
        proto, url = self._url.split('://')
        url = proto + '://' + self._user + ':' + self._passwd + '@' + url

In the "not" basic auth case the script path is added to the base url, while in the "use" basic auth case it is not (and, hence, the base url need to include the full script path).

Bug: 401 Unauthorized when using python 3.9

Let me use that simple code:

from dokuwikixmlrpc import DokuWikiClient
client = DokuWikiClient('https://wiki.example.net', 'remote-enabled-user', 'password')
print(client.page('home'))

With Python 3.7, i get the content of the home page, as expected. I recently updated my OS, and got python 3.9, on two different machines, i now got this stacktrace:

Traceback (most recent call last):
  File "/home/user/project/venv/lib/python3.9/site-packages/dokuwikixmlrpc.py", line 115, in catch_xmlerror
    return f(*args, **kwargs)
  File "/home/user/project/venv/lib/python3.9/site-packages/dokuwikixmlrpc.py", line 199, in page
    return self._xmlrpc.wiki.getPage(page_id)
  File "/usr/lib/python3.9/xmlrpc/client.py", line 1116, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python3.9/xmlrpc/client.py", line 1456, in __request
    response = self.__transport.request(
  File "/usr/lib/python3.9/xmlrpc/client.py", line 1160, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/usr/lib/python3.9/xmlrpc/client.py", line 1190, in single_request
    raise ProtocolError(
xmlrpc.client.ProtocolError: <ProtocolError for wiki.example.net/lib/exe/xmlrpc.php: 401 Unauthorized>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/project/showbug.py", line 12, in <module>
    print(client.page('home'))
  File "/home/user/project/venv/lib/python3.9/site-packages/dokuwikixmlrpc.py", line 119, in catch_xmlerror
    raise DokuWikiXMLRPCProtocolError(fault)
dokuwikixmlrpc.DokuWikiXMLRPCProtocolError: <DokuWikiXMLRPCProtocolError 401: 'Unauthorized' at wiki.example.net/lib/exe/xmlrpc.php>

Is there any chance python 3.9 changes something that makes the XML RPC protocol fail in any way ?
The only thing, apart new bugs in CPython itself, i can imagine right now is the new operators on dict, the new string methods, or some little details.

I tried running the code with -X oldparser to use the LL(1) parser (as 3.9 introduce the PEG one), but that didn't changed anything.

Please add parameters to getPagelist

Requesting dw.pagelist(':') gives all the pages, maybe many thousands. Users may be interested in limiting the depth of search:

dw.pagelist(':', {'depth': 1})

but that gives

TypeError: DokuWikiClient.pagelist() takes 2 positional arguments but 3 were given

It's reasonable to add the second parameter here:

    def pagelist(self, namespace):
        """Lists all pages within a given namespace."""
        return self._xmlrpc.dokuwiki.getPagelist(namespace, {})

Kind of

    def pagelist(self, namespace, opts = {'depth': 0, 'hash': False, 'skipacl': False}):
        """Lists all pages within a given namespace."""
        return self._xmlrpc.dokuwiki.getPagelist(namespace, opts)

should send an moer specific execption when receiving 'XML-RPC server not enabled.' from the server

Hello,

This will be way more readable than:

Traceback (most recent call last):
  File "script.py", line 1, in <module>
    from dokuwikixmlrpc import DokuWikiClient; DokuWikiClient("http://wiki.cerkinfo.be", "Bram", "p0ulet0478")
  File "/home/psycojoker/code/python/dokuwikixmlrpc/dokuwikixmlrpc.py", line 113, in __init__
    self.dokuwiki_version = self._dokuwiki_version()
  File "/home/psycojoker/code/python/dokuwikixmlrpc/dokuwikixmlrpc.py", line 145, in _dokuwiki_version
    return self._xmlrpc.dokuwiki.getVersion()
  File "/usr/lib/python2.7/xmlrpclib.py", line 1224, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python2.7/xmlrpclib.py", line 1578, in __request
    verbose=self.__verbose
  File "/usr/lib/python2.7/xmlrpclib.py", line 1264, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/usr/lib/python2.7/xmlrpclib.py", line 1297, in single_request
    return self.parse_response(response)
  File "/usr/lib/python2.7/xmlrpclib.py", line 1467, in parse_response
    p.feed(data)
  File "/usr/lib/python2.7/xmlrpclib.py", line 557, in feed
    self._parser.Parse(data, 0)
xml.parsers.expat.ExpatError: syntax error: line 1, column 0

Which doesn't inform in any manner of the actual error.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.