From 0814f6b313b307912dc21cea8b2770b47cc834c3 Mon Sep 17 00:00:00 2001 From: Fernando Jorge Mota Date: Wed, 15 Jul 2015 20:40:27 -0300 Subject: [PATCH 1/2] Fix bug where preview_session method does not use specified cache This commit simply fixes a bug where the method preview_session in API object does not use the passed in cache object. --- prismic/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prismic/api.py b/prismic/api.py index e8935b6..8fa5a06 100644 --- a/prismic/api.py +++ b/prismic/api.py @@ -85,7 +85,7 @@ def preview_session(self, token, link_resolver, default_url): :return: the URL to redirect the user to """ - main_document_id = get_json(token, request_handler=self.request_handler).get("mainDocument") + main_document_id = get_json(token, request_handler=self.request_handler, cache=self.cache).get("mainDocument") if main_document_id is None: return default_url response = self.form("everything").ref(token).query(predicates.at("document.id", main_document_id)).submit() From 8962ff8c7a757b2b7071dcf97f26c240d42e040c Mon Sep 17 00:00:00 2001 From: Fernando Jorge Mota Date: Wed, 15 Jul 2015 20:42:27 -0300 Subject: [PATCH 2/2] Fix bug where Cache-Control header is not found For some reason when calling preview session the cache control header is not specified in response. (as I can see) This commit makes the connection module do not emit a KeyError exception when the Cache-Control is not specified. --- prismic/connection.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prismic/connection.py b/prismic/connection.py index 501ba4a..8149062 100644 --- a/prismic/connection.py +++ b/prismic/connection.py @@ -66,7 +66,7 @@ def get_json(url, params=None, access_token=None, cache=None, ttl=None, request_ def get_max_age(headers): - expire_header = headers["Cache-Control"] + expire_header = headers.get("Cache-Control") if expire_header is not None: m = re.match("max-age=(\d+)", expire_header) if m: