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

Add check to call render on the response if it has a render method #11762

Merged
merged 3 commits into from
Feb 22, 2024
Merged
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
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
Loading