RapiClient: fix multi-authentication in Python 2.6
authorGuido Trotter <ultrotter@google.com>
Thu, 1 Jul 2010 13:36:52 +0000 (14:36 +0100)
committerGuido Trotter <ultrotter@google.com>
Thu, 1 Jul 2010 13:49:33 +0000 (14:49 +0100)
commit14ff387e9cff785977afc9526794656f8f9b7b2d
tree1837bda96f092b1f0897795c2294834e8060e15f
parent87e058d59fb648b43dd7c55f4238ebe3ec0fc7e0
RapiClient: fix multi-authentication in Python 2.6

In Python 2.6 the urllib2.HTTPBasicAuthHandler has a "retried" count for
failed authentications. The handler fails after 5 of them. To solve this
we reset the handler's "retried" member variable to 0 after every
successful request. This is a bit ugly, but makes the client work again
for more than 5 requests under all versions of Python.

Note that the digest authentication handler has a reset_retry_count()
method to do this, but the method is not defined for the basic
authentication handler, so we must reset the variable itself.

This member variable is unused in 2.4 and 2.5, so the change doesn't
affect the client under older Python versions.

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>
lib/rapi/client.py