@@ -64,13 +64,13 @@ class CookiesTransport(Transport):
6464 def __init__ (self ):
6565 Transport .__init__ (self )
6666 self ._cookies = dict ()
67-
67+
6868 def send_headers (self , connection , headers ):
6969 if self ._cookies :
70- cookies = map (lambda x : x [0 ] + '=' + x [1 ], self ._cookies .items ())
70+ cookies = map (lambda x : x [0 ] + '=' + x [1 ], self ._cookies .items ())
7171 connection .putheader ("Cookie" , "; " .join (cookies ))
7272 Transport .send_headers (self , connection , headers )
73-
73+
7474 def parse_response (self , response ):
7575 """parse and store cookie"""
7676 try :
@@ -91,7 +91,7 @@ def send_request(self, connection, handler, request_body):
9191 Transport .send_request (self , connection , handler , request_body )
9292 # set cookie below handler
9393 if self ._cookies :
94- cookies = map (lambda x : x [0 ] + '=' + x [1 ], self ._cookies .items ())
94+ cookies = map (lambda x : x [0 ] + '=' + x [1 ], self ._cookies .items ())
9595 connection .putheader ("Cookie" , "; " .join (cookies ))
9696
9797 def parse_response (self , response ):
@@ -125,12 +125,12 @@ class DokuWiki(object):
125125 print('unable to connect: %s' % err)
126126 """
127127
128- def __init__ (self , url , user , password , basicAuth = False , ** kwargs ):
128+ def __init__ (self , url , user , password , cookieAuth = False , ** kwargs ):
129129 """Initialize the object by connecting to the XMLRPC server."""
130130 # Initialize XMLRPC client.
131131 try :
132132 params = _URL_RE .search (url ).groupdict ()
133- if basicAuth :
133+ if cookieAuth == False :
134134 url = '%s://%s:%s@%s%s/lib/exe/xmlrpc.php' % (
135135 params ['proto' ], user , password , params ['host' ], params ['uri' ] or '' )
136136 else :
@@ -139,10 +139,13 @@ def __init__(self, url, user, password, basicAuth=False, **kwargs):
139139 except AttributeError :
140140 raise DokuWikiError ("invalid url '%s'" % url )
141141
142- if sys . version_info [ 0 ] == 3 :
143- self .proxy = ServerProxy (url , CookiesTransport (), ** kwargs )
142+ if cookieAuth == False :
143+ self .proxy = ServerProxy (url , ** kwargs )
144144 else :
145- self .proxy = ServerProxy (url , CookiesTransport2 (), ** kwargs )
145+ if sys .version_info [0 ] == 3 :
146+ self .proxy = ServerProxy (url , CookiesTransport (), ** kwargs )
147+ else :
148+ self .proxy = ServerProxy (url , CookiesTransport2 (), ** kwargs )
146149
147150 # Force login to check the connection.
148151 if not self .login (user , password ):
0 commit comments