equal
deleted
inserted
replaced
23 |
23 |
24 |
24 |
25 import logging |
25 import logging |
26 |
26 |
27 from google.appengine.api import memcache |
27 from google.appengine.api import memcache |
28 from google.appengine.api import users |
28 |
|
29 from soc.logic import accounts |
29 |
30 |
30 import soc.cache.base |
31 import soc.cache.base |
31 |
32 |
32 |
33 |
33 def key(entity): |
34 def key(entity): |
41 """Retrieves the sidebar for the specified user from the memcache. |
42 """Retrieves the sidebar for the specified user from the memcache. |
42 """ |
43 """ |
43 |
44 |
44 # only cache the page for non-logged-in users |
45 # only cache the page for non-logged-in users |
45 # TODO: figure out how to cache everything but the sidebar |
46 # TODO: figure out how to cache everything but the sidebar |
46 if users.get_current_user(): |
47 # also, no need to normalize as we don't use it anyway |
|
48 if accounts.getCurrentAccount(normalize=False): |
47 return (None, None) |
49 return (None, None) |
48 |
50 |
49 entity = self._logic.getFromKeyFields(kwargs) |
51 entity = self._logic.getFromKeyFields(kwargs) |
50 |
52 |
51 # if we can't retrieve the entity, leave it to the actual method |
53 # if we can't retrieve the entity, leave it to the actual method |
62 Args: |
64 Args: |
63 sidebar: the sidebar to be cached |
65 sidebar: the sidebar to be cached |
64 """ |
66 """ |
65 |
67 |
66 # no sense in storing anything if we won't query it later on |
68 # no sense in storing anything if we won't query it later on |
67 if users.get_current_user(): |
69 # also, no need to normalize as we don't use it anyway |
|
70 if accounts.getCurrentAccount(normalize=False): |
68 return |
71 return |
69 |
72 |
70 # Store sidebar for just ten minutes to force a refresh every so often |
73 # Store sidebar for just ten minutes to force a refresh every so often |
71 retention = 10*60 |
74 retention = 10*60 |
72 |
75 |