Skip to content

Commit 8057a5e

Browse files
committed
Update documentation for cookie based authentication
1 parent 24ef147 commit 8057a5e

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

dokuwiki.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class DokuWikiError(Exception):
6161
"""Exception raised by this module when there is an error."""
6262
pass
6363

64+
6465
def CookiesTransport(proto='https'):
6566
"""Generate transport class when using cookie based authentication."""
6667
_TransportClass_ = Transport if proto == 'http' else SafeTransport
@@ -116,28 +117,34 @@ def parse_response(self, response):
116117
return CookiesTransport2() if PY_VERSION == 2 else CookiesTransport()
117118

118119
class DokuWiki(object):
119-
"""Initialize a connection to a DokuWiki wiki. *url*, *user* and
120-
*password* are respectively the URL, the login and the password for
121-
connecting to the wiki. *kwargs* are `xmlrpclib`/`xmlrpc.client`
120+
"""Initialize a connection to a DokuWiki wiki. ``url``, ``user`` and
121+
``password`` are respectively the URL, the login and the password for
122+
connecting to the wiki. ``kwargs`` are `xmlrpclib`/`xmlrpc.client`
122123
**ServerProxy** parameters.
123124
124-
The exception `DokuWikiError` is raised if the authentification
125-
fails but others exceptions (like ``gaierror`` for invalid domain,
126-
``ProtocolError`` for an invalid wiki, ...) are not catched.
125+
The exception `DokuWikiError` is raised if the authentication
126+
fails but others exceptions (like `socket.gaierror` for invalid domain,
127+
`xmlrpc.client.ProtocolError` for an invalid wiki, ...) are not catched.
127128
128129
.. code::
129130
130131
try:
131-
wiki = dokuwiki.DokuWiki('URL', 'USER', 'PASSWORD', cookieAuth=False)
132+
wiki = dokuwiki.DokuWiki('URL', 'USER', 'PASSWORD')
132133
except (DokuWikiError, Exception) as err:
133134
print('unable to connect: %s' % err)
134135
135136
.. note::
136137
137-
The URL format is: `PROTO://FQDN[/PATH]` (*https://www.example.com/dokuwiki*
138+
The URL format is: ``PROTO://FQDN[/PATH]`` (*https://www.example.com/dokuwiki*
138139
for example).
139-
"""
140140
141+
To use cookie based authentication (use HTTP cookies instead of passing login
142+
and password in the URI), set ``cookieAuth`` parameter to *True*:
143+
144+
.. code::
145+
146+
wiki = dokuwiki.DokuWiki('URL', 'USER', 'PASSWORD', cookieAuth=True)
147+
"""
141148
def __init__(self, url, user, password, **kwargs):
142149
"""Initialize the object by connecting to the XMLRPC server."""
143150
# Parse input URL
@@ -188,6 +195,7 @@ def send(self, command, *args, **kwargs):
188195
except ExpatError as err:
189196
if str(err) != ERR:
190197
raise DokuWikiError(err)
198+
191199
@property
192200
def version(self):
193201
"""Property that returns the DokuWiki version of the remote Wiki."""

0 commit comments

Comments
 (0)