Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for newer requests-cache #105

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions tests/test_tvdb_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,12 @@ def __init__(self, _name, fc_base_dir, **options):
self.keys_map = FileCacheDict(base_dir=fc_base_dir)


requests_cache.backends.registry['tvdb_api_file_cache'] = FileCache


def get_test_cache_session():
here = os.path.dirname(os.path.abspath(__file__))
additional = "_py2" if sys.version_info[0] == 2 else ""
sess = requests_cache.CachedSession(
backend="tvdb_api_file_cache",
backend="filesystem",
fc_base_dir=os.path.join(here, "httpcache%s" % additional),
include_get_headers=True,
allowable_codes=(200, 404),
Expand Down
6 changes: 3 additions & 3 deletions tvdb_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ def __repr__(self):
return "<Actor %r>" % self.get("name")


def create_key(self, request):
def create_key(self, request, **kwargs):
"""A new cache_key algo is required as the authentication token
changes with each run. Also there are other header params which
also change with each request (e.g. timestamp). Excluding all
Expand All @@ -544,7 +544,7 @@ def create_key(self, request):
cache is to be used thus saving host and network traffic.
"""

if self._ignored_parameters:
if self.ignored_parameters:
url, body = self._remove_ignored_parameters(request)
else:
url, body = request.url, request.body
Expand All @@ -554,7 +554,7 @@ def create_key(self, request):
if request.body:
key.update(_to_bytes(body))
else:
if self._include_get_headers and request.headers != _DEFAULT_HEADERS:
if self.match_headers and request.headers != _DEFAULT_HEADERS:
for name, value in sorted(request.headers.items()):
# include only Accept-Language as it is important for context
if name in ['Accept-Language']:
Expand Down