Fixed bug in cache controller that was causing session handler to return NoneType

This commit is contained in:
echel0n 2014-03-29 01:45:49 -07:00
parent f0ffae31a6
commit c2f7f766f4
2 changed files with 4 additions and 3 deletions

View file

@ -2,13 +2,14 @@ from requests.adapters import HTTPAdapter
from cachecontrol.controller import CacheController
from cachecontrol.cache import DictCache
from cachecontrol.session import CacheControlSession
class CacheControlAdapter(HTTPAdapter):
invalidating_methods = set(['PUT', 'DELETE'])
def __init__(self, sess=None, cache=None, cache_etags=True, *args, **kw):
super(CacheControlAdapter, self).__init__(*args, **kw)
self.sess = sess or CacheControlSession()
self.cache = cache or DictCache()
self.controller = CacheController(sess=sess, cache=cache, cache_etags=cache_etags)

View file

@ -8,7 +8,7 @@ import datetime
from cachecontrol.cache import DictCache
from cachecontrol.compat import parsedate_tz
from cachecontrol.session import CacheControlSession
URI = re.compile(r"^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?")
@ -28,7 +28,7 @@ class CacheController(object):
def __init__(self, sess=None, cache=None, cache_etags=True):
self.cache = cache or DictCache()
self.cache_etags = cache_etags
self.sess = sess
self.sess = sess or CacheControlSession()
def _urlnorm(self, uri):
"""Normalize the URL to create a safe key for the cache"""