0003-decorators-remove-broken-and-unused-decorator-56982.patch
src/authentic2/decorators.py | ||
---|---|---|
239 | 239 |
return request.__dict__.setdefault(self.__class__.__name__, {}) |
240 | 240 | |
241 | 241 | |
242 |
class DjangoCache(SimpleDictionnaryCacheMixin, CacheDecoratorBase): |
|
243 |
@property |
|
244 |
def cache(self): |
|
245 |
return django_cache |
|
246 | ||
247 |
def set(self, key, value): |
|
248 |
self.cache.set(key, value, timeout=self.timeout) |
|
249 | ||
250 |
def delete(self, key, value): |
|
251 |
if self.get(key) == value: |
|
252 |
self.delete(key) |
|
253 | ||
254 | ||
255 | 242 |
class PickleCacheMixin: |
256 | 243 |
def set(self, key, value): |
257 | 244 |
value, tstamp = value |
tests/cache_urls.py | ||
---|---|---|
17 | 17 |
from django.conf.urls import url |
18 | 18 |
from django.http import HttpResponse |
19 | 19 | |
20 |
from authentic2.decorators import DjangoCache, SessionCache |
|
21 | ||
22 | ||
23 |
@DjangoCache |
|
24 |
def cached_function(): |
|
25 |
import random |
|
26 | ||
27 |
return random.random() |
|
28 | ||
29 | ||
30 |
def cached_view(self): |
|
31 |
return HttpResponse('%s' % cached_function()) |
|
20 |
from authentic2.decorators import SessionCache |
|
32 | 21 | |
33 | 22 | |
34 | 23 |
@SessionCache() |
... | ... | |
43 | 32 |
return HttpResponse('%s' % value) |
44 | 33 | |
45 | 34 | |
46 |
urlpatterns = [url(r'^django_cache/$', cached_view), url(r'^session_cache/$', session_cache)] |
|
35 |
urlpatterns = [url(r'^session_cache/$', session_cache)] |
|
47 |
- |