



  

dokuwiki 1.2.1 documentation

 [dokuwiki](index.html#document-index) 

 stable

 

[dokuwiki](index.html#document-index)

* [Docs](index.html#document-index) »

* dokuwiki 1.2.1 documentation

* [Edit on GitHub](https://github.com/fmenabe/python-dokuwiki/blob/88ae57e6245331c106e9bb2eb23ab694302e1b09/doc/source/index.rst)

---

python-dokuwiki documentation[¶](#python-dokuwiki-documentation "Permalink to this headline")

=============================================================================================

This python module aims to manage

[DokuWiki](https://www.dokuwiki.org/dokuwiki) wikis by using the

provided [XML-RPC API](https://www.dokuwiki.org/devel:xmlrpc). It is

compatible with python2.7 and python3+.

Installation[¶](#installation "Permalink to this headline")

-----------------------------------------------------------

It is on [PyPi](https://pypi.python.org/pypi/dokuwiki) so you can use

the `pip` command to install it:

```

pip install dokuwiki

```

Otherwise sources are in [github](https://github.com/fmenabe/python-dokuwiki)

API[¶](#api "Permalink to this headline")

-----------------------------------------

### Functions[¶](#functions "Permalink to this headline")

`dokuwiki.``date`(*date*)[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L38-L46)[¶](#dokuwiki.date "Permalink to this definition")

DokuWiki returns dates of [`xmlrpclib`](https://docs.python.org/2/library/xmlrpclib.html#module-xmlrpclib "(in Python v2.7)")/[`xmlrpc.client`](https://docs.python.org/3/library/xmlrpc.client.html#module-xmlrpc.client "(in Python v3.10)") `DateTime`

type and the format changes between DokuWiki versions … This function

convert *date* to a [`datetime`](https://docs.python.org/3/library/datetime.html#module-datetime "(in Python v3.10)") object.

`dokuwiki.``utc2local`(*date*)[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L48-L57)[¶](#dokuwiki.utc2local "Permalink to this definition")

DokuWiki returns date with a +0000 timezone. This function convert *date*

to the local time.

### Exceptions[¶](#exceptions "Permalink to this headline")

*class* `dokuwiki.``DokuWikiError`[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L60-L62)[¶](#dokuwiki.DokuWikiError "Permalink to this definition")

Exception raised by this module when there is an error.

### Main object[¶](#main-object "Permalink to this headline")

*class* `dokuwiki.``DokuWiki`(*url*, *user*, *password*, *\*\*kwargs*)[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L119-L256)[¶](#dokuwiki.DokuWiki "Permalink to this definition")

Initialize a connection to a DokuWiki wiki. `url`, `user` and

`password` are respectively the URL, the login and the password for

connecting to the wiki. `kwargs` are [`xmlrpclib`](https://docs.python.org/2/library/xmlrpclib.html#module-xmlrpclib "(in Python v2.7)")/[`xmlrpc.client`](https://docs.python.org/3/library/xmlrpc.client.html#module-xmlrpc.client "(in Python v3.10)")

**ServerProxy** parameters.

The exception [`DokuWikiError`](#dokuwiki.DokuWikiError "dokuwiki.DokuWikiError") is raised if the authentication

fails but others exceptions (like [`socket.gaierror`](https://docs.python.org/3/library/socket.html#socket.gaierror "(in Python v3.10)") for invalid domain,

[`xmlrpc.client.ProtocolError`](https://docs.python.org/3/library/xmlrpc.client.html#xmlrpc.client.ProtocolError "(in Python v3.10)") for an invalid wiki, …) are not catched.

```

try:

    wiki = dokuwiki.DokuWiki('URL', 'USER', 'PASSWORD')

except (DokuWikiError, Exception) as err:

    print('unable to connect: %s' % err)

```

Note

The URL format is: `PROTO://FQDN[/PATH]` (*https://www.example.com/dokuwiki*

for example).

To use cookie based authentication (use HTTP cookies instead of passing login

and password in the URI), set `cookieAuth` parameter to *True*:

```

wiki = dokuwiki.DokuWiki('URL', 'USER', 'PASSWORD', cookieAuth=True)

```

`send`(*command*, *\*args*, *\*\*kwargs*)[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L184-L206)[¶](#dokuwiki.DokuWiki.send "Permalink to this definition")

Generic method for executing an XML-RPC *command*. *args* and

*kwargs* are the arguments and parameters needed by the command.

`version`[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L208-L211)[¶](#dokuwiki.DokuWiki.version "Permalink to this definition")

Property that returns the DokuWiki version of the remote Wiki.

`time`[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L213-L218)[¶](#dokuwiki.DokuWiki.time "Permalink to this definition")

Property that returns the current time at the remote wiki server as

Unix timestamp.

`xmlrpc_version`[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L220-L226)[¶](#dokuwiki.DokuWiki.xmlrpc_version "Permalink to this definition")

Property that returns the XML RPC interface version of the remote

Wiki. This is DokuWiki implementation specific and independent of the

supported standard API version returned by `wiki.getRPCVersionSupported`.

`xmlrpc_supported_version`[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L228-L231)[¶](#dokuwiki.DokuWiki.xmlrpc_supported_version "Permalink to this definition")

Property that returns *2* with the supported RPC API version.

`title`[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L233-L236)[¶](#dokuwiki.DokuWiki.title "Permalink to this definition")

Property that returns the title of the wiki.

`login`(*user*, *password*)[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L238-L241)[¶](#dokuwiki.DokuWiki.login "Permalink to this definition")

Log to the wiki using *user* and *password* credentials. It returns

a boolean that indicates if the user succesfully authenticate.

`add_acl`(*scope*, *user*, *permission*)[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L243-L249)[¶](#dokuwiki.DokuWiki.add_acl "Permalink to this definition")

Add an [ACL](https://www.dokuwiki.org/acl) rule that restricts

the page/namespace *scope* to *user* (use *@group* syntax for groups)

with *permission* level. It returns a boolean that indicate if the rule

was correctly added.

`del_acl`(*scope*, *user*)[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L251-L256)[¶](#dokuwiki.DokuWiki.del_acl "Permalink to this definition")

Delete any ACL matching the given *scope* and *user* (or group if

*@group* syntax is used). It returns a boolean that indicate if the rule

was correctly removed.

### Pages[¶](#pages "Permalink to this headline")

*class* `dokuwiki.``_Pages`(*dokuwiki*)[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L259-L383)[¶](#dokuwiki._Pages "Permalink to this definition")

This object regroup methods for managing pages of a DokuWiki. This object

is accessible from the `pages` property of an [`DokuWiki`](#dokuwiki.DokuWiki "dokuwiki.DokuWiki") instance:

```

wiki = dokuwiki.DokuWiki('URL', 'User', 'Password')

wiki.pages.list()

```

`list`(*namespace='/'*, *\*\*options*)[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L270-L279)[¶](#dokuwiki._Pages.list "Permalink to this definition")

List all pages of the given *namespace*.

Valid *options* are:

> 

> * *depth*: (int) recursion level, 0 for all

> * *hash*: (bool) do an md5 sum of content

> * *skipacl*: (bool) list everything regardless of ACL

> 

> 

> 

`changes`(*timestamp*)[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L281-L289)[¶](#dokuwiki._Pages.changes "Permalink to this definition")

Returns a list of changes since given *timestamp*.

For example, for returning all changes since *2016-01-01*:

```

from datetime import datetime

wiki.pages.changes(datetime(2016, 1, 1).timestamp())

```

`search`(*string*)[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L291-L295)[¶](#dokuwiki._Pages.search "Permalink to this definition")

Performs a fulltext search on *string* and returns the first 15

results.

`versions`(*page*, *offset=0*)[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L297-L301)[¶](#dokuwiki._Pages.versions "Permalink to this definition")

Returns the available versions of *page*. *offset* can be used to

list earlier versions in the history.

`info`(*page*, *version=None*)[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L303-L309)[¶](#dokuwiki._Pages.info "Permalink to this definition")

Returns informations of *page*. Informations of the last version

is returned if *version* is not set.

`get`(*page*, *version=None*)[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L311-L317)[¶](#dokuwiki._Pages.get "Permalink to this definition")

Returns the content of *page*. The content of the last version is

returned if *version* is not set.

`append`(*page*, *content*, *\*\*options*)[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L320-L328)[¶](#dokuwiki._Pages.append "Permalink to this definition")

Appends *content* text to *page*.

Valid *options* are:

> 

> * *sum*: (str) change summary

> * *minor*: (bool) whether this is a minor change

> 

> 

> 

`html`(*page*, *version=None*)[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L330-L336)[¶](#dokuwiki._Pages.html "Permalink to this definition")

Returns HTML content of *page*. The HTML content of the last version

of the page is returned if *version* is not set.

`set`(*page*, *content*, *\*\*options*)[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L338-L353)[¶](#dokuwiki._Pages.set "Permalink to this definition")

Set/replace the *content* of *page*.

Valid *options* are:

> 

> * *sum*: (str) change summary

> * *minor*: (bool) whether this is a minor change

> 

> 

> 

`delete`(*page*)[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L355-L357)[¶](#dokuwiki._Pages.delete "Permalink to this definition")

Delete *page* by setting an empty content.

`lock`(*page*)[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L359-L364)[¶](#dokuwiki._Pages.lock "Permalink to this definition")

Locks *page*.

`unlock`(*page*)[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L366-L371)[¶](#dokuwiki._Pages.unlock "Permalink to this definition")

Unlocks *page*.

`permission`(*page*)[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L373-L375)[¶](#dokuwiki._Pages.permission "Permalink to this definition")

Returns the permission level of *page*.

`links`(*page*)[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L377-L379)[¶](#dokuwiki._Pages.links "Permalink to this definition")

Returns a list of all links contained in *page*.

`backlinks`(*page*)[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L381-L383)[¶](#dokuwiki._Pages.backlinks "Permalink to this definition")

Returns a list of all links referencing *page*.

### Medias[¶](#medias "Permalink to this headline")

*class* `dokuwiki.``_Medias`(*dokuwiki*)[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L386-L464)[¶](#dokuwiki._Medias "Permalink to this definition")

This object regroup methods for managing medias of a DokuWiki. This

object is accessible from the `medias` property of an [`DokuWiki`](#dokuwiki.DokuWiki "dokuwiki.DokuWiki")

instance:

```

wiki = dokuwiki.DokuWiki('URL', 'User', 'Password')

wiki.medias.list()

```

`list`(*namespace='/'*, *\*\*options*)[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L397-L407)[¶](#dokuwiki._Medias.list "Permalink to this definition")

Returns all medias of the given *namespace*.

Valid *options* are:

> 

> * *depth*: (int) recursion level, 0 for all

> * *skipacl*: (bool) skip acl checking

> * *pattern*: (str) check given pattern

> * *hash*: (bool) add hashes to result list

> 

> 

> 

`changes`(*timestamp*)[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L409-L417)[¶](#dokuwiki._Medias.changes "Permalink to this definition")

Returns the list of medias changed since given *timestamp*.

For example, for returning all changes since *2016-01-01*:

```

from datetime import datetime

wiki.medias.changes(datetime(2016, 1, 1).timestamp())

```

`get`(*media*, *dirpath=None*, *filename=None*, *overwrite=False*, *b64decode=False*)[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L419-L441)[¶](#dokuwiki._Medias.get "Permalink to this definition")

Returns the binary data of *media* or save it to a file. If *dirpath*

is not set the binary data is returned, otherwise the data is saved

to a file. By default, the filename is the name of the media but it can

be changed with *filename* parameter. *overwrite* parameter allow to

overwrite the file if it already exists locally.

`info`(*media*)[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L443-L445)[¶](#dokuwiki._Medias.info "Permalink to this definition")

Returns informations of *media*.

`add`(*media*, *filepath*, *overwrite=True*)[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L447-L453)[¶](#dokuwiki._Medias.add "Permalink to this definition")

Set *media* from local file *filepath*. *overwrite* parameter specify

if the media must be overwrite if it exists remotely.

`set`(*media*, *\_bytes*, *overwrite=True*, *b64encode=False*)[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L455-L460)[¶](#dokuwiki._Medias.set "Permalink to this definition")

Set *media* from *\_bytes*. *overwrite* parameter specify if the media

must be overwrite if it exists remotely.

`delete`(*media*)[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L462-L464)[¶](#dokuwiki._Medias.delete "Permalink to this definition")

Delete *media*.

### Structs[¶](#structs "Permalink to this headline")

*class* `dokuwiki.``_Structs`(*dokuwiki*)[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L467-L487)[¶](#dokuwiki._Structs "Permalink to this definition")

`get_data`(*page*, *schema=''*, *timestamp=0*)[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L472-L474)[¶](#dokuwiki._Structs.get_data "Permalink to this definition")

Get the structured data of a given page.

`save_data`(*page*, *data*, *summary=''*, *minor=False*)[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L476-L478)[¶](#dokuwiki._Structs.save_data "Permalink to this definition")

Saves data for a given page (creates a new revision).

`get_schema`(*name=''*)[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L480-L482)[¶](#dokuwiki._Structs.get_schema "Permalink to this definition")

Get info about existing schemas columns.

`get_aggregation_data`(*schemas*, *columns*, *data\_filter=[]*, *sort=''*)[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L484-L487)[¶](#dokuwiki._Structs.get_aggregation_data "Permalink to this definition")

Get the data that would be shown in an aggregation.

### Dataentries[¶](#dataentries "Permalink to this headline")

*class* `dokuwiki.``Dataentry`[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L490-L539)[¶](#dokuwiki.Dataentry "Permalink to this definition")

Object that manage [data entries](https://www.dokuwiki.org/plugin:data).

*static* `get`(*content*, *keep\_order=False*)[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L493-L520)[¶](#dokuwiki.Dataentry.get "Permalink to this definition")

Get dataentry from *content*. *keep\_order* indicates whether to

return an ordered dictionary.

*static* `gen`(*name*, *data*)[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L522-L526)[¶](#dokuwiki.Dataentry.gen "Permalink to this definition")

Generate dataentry *name* from *data*.

*static* `ignore`(*content*)[[source]](https://github.com/fmenabe/python-dokuwiki/blob/1.2.1/dokuwiki.py#L528-L539)[¶](#dokuwiki.Dataentry.ignore "Permalink to this definition")

Remove dataentry from *content*.

