Skip to content

Commit

Permalink
Make sure callback doesnt return boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
jpadilla committed Jan 15, 2020
1 parent 525d0d2 commit 000ae80
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions suministrospr/utils/mixins.py
Expand Up @@ -9,6 +9,10 @@ class CacheMixin:
def get_cache_key(self):
return self.cache_key

def _cache_rendered_response(self, response):
cache_key = self.get_cache_key()
cache.set(cache_key, response, self.cache_timeout)

def dispatch(self, *args, **kwargs):
cache_key = self.get_cache_key()

Expand All @@ -21,8 +25,6 @@ def dispatch(self, *args, **kwargs):
response = super().dispatch(*args, **kwargs)

if cache_key:
response.add_post_render_callback(
lambda r: cache.set(cache_key, r, self.cache_timeout)
)
response.add_post_render_callback(self._cache_rendered_response)

return response

0 comments on commit 000ae80

Please sign in to comment.