new settings module

This commit is contained in:
Kenneth Reitz
2011-05-20 12:53:20 -04:00
parent ef81c16611
commit ba79a2eb97
2 changed files with 40 additions and 1 deletions
+1 -1
View File
@@ -19,7 +19,7 @@ __license__ = 'ISC'
__copyright__ = 'Copyright 2011 Kenneth Reitz'
from models import HTTPError, auth_manager
from api import *
from exceptions import *
from settings import *
+39
View File
@@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-
"""
requests.settings
~~~~~~~~~~~~~~~~~
This module provides the Requests settings feature set.
"""
class Settings(object):
def __init__(self, **settings):
self._cache_settings(**settings)
self._alter_settings(**settings)
def __enter__(self):
pass
def __exit__(self, type, value, traceback):
self._restore_settings()
def _cache_settings(self, **settings):
self.cache = {}
for setting in settings:
self.cache[setting] = globals()[setting]
def _alter_settings(self, **settings):
for setting, value in settings.items():
globals()[setting] = value
def _restore_settings(self):
for setting, value in self.cache.items():
globals()[setting] = value
settings = Settings
timeout = None