From c2f7f766f4b2ca5d578c1774cfc58cc3e28dc66d Mon Sep 17 00:00:00 2001 From: echel0n Date: Sat, 29 Mar 2014 01:45:49 -0700 Subject: [PATCH] Fixed bug in cache controller that was causing session handler to return NoneType --- lib/cachecontrol/adapter.py | 3 ++- lib/cachecontrol/controller.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/cachecontrol/adapter.py b/lib/cachecontrol/adapter.py index 9bc25c22..264fb1be 100644 --- a/lib/cachecontrol/adapter.py +++ b/lib/cachecontrol/adapter.py @@ -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) diff --git a/lib/cachecontrol/controller.py b/lib/cachecontrol/controller.py index 680479a3..9dfea3cc 100644 --- a/lib/cachecontrol/controller.py +++ b/lib/cachecontrol/controller.py @@ -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"""