Skip to content

Commit 6fc9d2c

Browse files
committed
Fix bug in new memcache view policy
1 parent 5977948 commit 6fc9d2c

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

view.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ def full_render(self, handler, template_info, more_params):
172172
def render_or_get_cache(self, handler, template_info, template_params={}):
173173
"""Checks if there's a non-stale cached version of this view,
174174
and if so, return it."""
175+
user = users.get_current_user()
176+
key = handler.request.url
175177
if self.cache_time:
176178
# See if there's a cache within time.
177179
# The cache key suggests a problem with the url <-> function
@@ -180,19 +182,16 @@ def render_or_get_cache(self, handler, template_info, template_params={}):
180182
# resource. If we have to include states like "user?" and
181183
# "admin?", then it suggests these flags should be in url.
182184
# TODO - Think about the above with respect to caching.
183-
user = users.get_current_user()
184-
if user:
185-
return None
186-
key = handler.request.url
187-
try:
188-
data = memcache.get(key)
189-
except ValueError:
190-
data = None
191-
if data is not None:
192-
logging.debug("Using cache for %s", template_info['file'])
193-
return data
194-
else:
195-
logging.debug("Memcached miss using key: %s", key)
185+
if not user:
186+
try:
187+
data = memcache.get(key)
188+
except ValueError:
189+
data = None
190+
if data is not None:
191+
logging.debug("Using cache for %s", template_info['file'])
192+
return data
193+
else:
194+
logging.debug("Memcached miss using key: %s", key)
196195

197196
output = self.full_render(handler, template_info, template_params)
198197
if self.cache_time:

0 commit comments

Comments
 (0)