From: Kenneth Reitz Date: Sun, 23 Oct 2011 15:15:42 +0000 (-0400) Subject: Use new authentication style in models X-Git-Tag: v0.7.1~1^2~16 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=495c3d500640ce39d53292fd9846a2354d203675;p=services%2Fpython-requests.git Use new authentication style in models :metal: --- diff --git a/requests/models.py b/requests/models.py index 852dbbd..cb10175 100644 --- a/requests/models.py +++ b/requests/models.py @@ -94,7 +94,9 @@ class Request(object): #: content and metadata of HTTP Response, once :attr:`sent `. self.response = Response() - # if isinstance(auth, (list, tuple)): + if isinstance(auth, (list, tuple)): + from .auth import http_basic + auth = (http_basic, auth) # auth = AuthObject(*auth) # if not auth: # auth = auth_manager.get_auth(self.url) @@ -138,7 +140,7 @@ class Request(object): if self.cookies is not None: _handlers.append(urllib2.HTTPCookieProcessor(self.cookies)) - # if self.auth: + # if not isinstance(self.auth.handler, # (urllib2.AbstractBasicAuthHandler, # urllib2.AbstractDigestAuthHandler)): @@ -348,6 +350,13 @@ class Request(object): data = self._enc_data headers = {} + if self.auth: + auth_func, auth_args = self.auth + + r = auth_func(self, *auth_args) + + self.__dict__.update(r.__dict__) + # Build the Urllib2 Request. req = _Request(url, data=data, headers=headers, method=self.method)