Skip to content

Commit

Permalink
Merge pull request #11762 from KshitijThareja/10506
Browse files Browse the repository at this point in the history
Add check to call render on the response if it has a render method
  • Loading branch information
bjester authored Feb 22, 2024
2 parents 1f5fa7c + 1540ece commit 9dbe675
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions kolibri/core/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,12 +339,16 @@ def cache_no_user_data(view_func):
_response = local()

def render_and_cache(response, cache_key):
response.render()
etag = hashlib.md5(
kolibri_version.encode("utf-8") + str(response.content).encode("utf-8")
).hexdigest()
cache.set(cache_key, etag, CACHE_TIMEOUT)
return etag
if hasattr(response, "render") and callable(response.render):
response.render()
if response.content:
etag = hashlib.md5(
kolibri_version.encode("utf-8") + str(response.content).encode("utf-8")
).hexdigest()
cache.set(cache_key, etag, CACHE_TIMEOUT)
return etag
else:
return None

def calculate_spa_etag(*args, **kwargs):
# Clear the local thread 'response' property
Expand Down

0 comments on commit 9dbe675

Please sign in to comment.