Skip to content
Myr

Merge pull request #35 from jgorset/requests

Before adoption: this commit came in with the history the project adopted, so no landing records it.

--- Ive completed the migration of the requests settings to the new `settings` module, but my attempt to facilitate for manipulating settings outside of the context manager (eg. `requests.settings.timeout = 5`) has been thwarted by the namespace collision of the context manager and the module. Im probably just being stupid. Youll figure it out. Conflicts: requests/api.py

authored by Kenneth Reitz · committed by Kenneth Reitz · parents 0b29964, 7d0374d · Browse files · 4 files+7 added−37 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+7 added−37 removed

  • other:+7 added−37 removed

4 files+7 added−37 removed

modified:requests/__init__.py-29 removed
1# -*- coding: utf-8 -*-23import inspect43import packages4from core import *56from core import __version__910timeout = None1112class settings:13 14 def __init__(self, **settings):15 self._cache_settings(**settings)16 self._alter_settings(**settings)17 18 def __enter__(self):19 pass20 21 def __exit__(self, type, value, traceback):22 self._restore_settings()23 24 def _cache_settings(self, **settings):25 self.cache = {}26 for setting in settings:27 self.cache[setting] = globals()[setting]28 29 def _alter_settings(self, **settings):30 for setting, value in settings.items():31 globals()[setting] = value32 33 def _restore_settings(self):34 for setting, value in self.cache.items():35 globals()[setting] = value
modified:requests/api.py+3 added-3 removed
10 unmodified lines
1112"""1314import requests15import settings16from .models import Request, Response, AuthManager, AuthObject, auth_manager171819__all__ = ('request', 'get', 'head', 'post', 'put', 'delete')
18 unmodified lines
3839 r = Request(method=method, url=url, data=data, headers=kwargs.pop('headers', {}),40 cookiejar=kwargs.pop('cookies', None), files=kwargs.pop('files', None),41 auth=kwargs.pop('auth', auth_manager.get_auth(url)),41 timeout=kwargs.pop('timeout', requests.timeout),42 allow_redirects=kwargs.pop('allow_redirects', requests.timeout)43 )42 timeout=kwargs.pop('timeout', settings.timeout))43 44 r.send()4546 return r.response47
71 unmodified lines
modified:requests/core.py+1 added-1 removed
20 unmodified lines
2122from models import HTTPError, auth_manager23from api import *24from exceptions import *25from settings import *25from settings import Settings as settings
modified:requests/settings.py+3 added-4 removed
6 unmodified lines
7This module provides the Requests settings feature set.89"""1011# Time (in seconds) to allow the request to connect to12# the remote host before timing it out.13timeout = None1415class Settings(object):1617 def __init__(self, **settings):
17 unmodified lines
3536 def _restore_settings(self):37 for setting, value in self.cache.items():38 globals()[setting] = value363738settings = Settings39timeout = None