This commit is contained in:
Kenneth Reitz
2011-05-22 13:55:13 -04:00
parent c0faa9e79c
commit bc290f62d7
2 changed files with 8 additions and 6 deletions
+6 -6
View File
@@ -36,12 +36,12 @@ def request(method, url, **kwargs):
"""
data = kwargs.pop('data', dict()) or kwargs.pop('params', dict())
r = Request(method=method, url=url, data=data, headers=kwargs.pop('headers', {}),
cookiejar=kwargs.pop('cookies', None),
files=kwargs.pop('files', None),
auth=kwargs.pop('auth', auth_manager.get_auth(url)),
timeout=kwargs.pop('timeout', config.settings.timeout),
allow_redirects=kwargs.pop('allow_redirects', None)
r = Request(method=method, url=url, data=data, headers=kwargs.pop('headers', dict()),
cookiejar=kwargs.get('cookies', None),
files=kwargs.get('files', None),
auth=kwargs.get('auth', auth_manager.get_auth(url)),
timeout=kwargs.get('timeout', config.settings.timeout),
allow_redirects=kwargs.get('allow_redirects', None)
)
r.send()
+2
View File
@@ -26,6 +26,7 @@ class Settings(object):
# cache previous settings for __exit__
r.__cache = self.__dict__.copy()
map(self.__cache.setdefault, self.__attrs__)
# set new settings
self.__dict__.update(*args, **kwargs)
@@ -40,6 +41,7 @@ class Settings(object):
def __exit__(self, *args):
# restore cached copy
print '>>> {0}'.format(self.__cache)
self.__dict__.update(self.__cache.copy())
del self.__cache