Navigation Menu

Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
allow using the cache_page decorator without () if no args are used. …
Browse files Browse the repository at this point in the history
…bug 582285.
  • Loading branch information
Fred Wenzel committed Jul 27, 2010
1 parent 43d2b6e commit 40d19d4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
10 changes: 5 additions & 5 deletions apps/dashboard/views.py
Expand Up @@ -14,7 +14,7 @@
from .forms import PeriodForm, PERIOD_DELTAS


@cache_page()
@cache_page
def dashboard(request):
"""Front page view."""
search_form = ReporterSearchForm()
Expand All @@ -40,7 +40,7 @@ def wrapped(request, period='1d', *args, **kwargs):
return wrapped


@cache_page()
@cache_page
@period_to_date
def sentiment(request, date_start, date_end):
"""AJAX action returning a summary of positive/negative sentiments."""
Expand All @@ -50,7 +50,7 @@ def sentiment(request, date_start, date_end):
return jingo.render(request, 'dashboard/sentiments.html', data)


@cache_page()
@cache_page
@period_to_date
def trends(request, date_start, date_end):
"""AJAX action returning a summary of frequent terms."""
Expand All @@ -62,7 +62,7 @@ def trends(request, date_start, date_end):
return jingo.render(request, 'dashboard/trends.html', data)


@cache_page()
@cache_page
@period_to_date
def demographics(request, date_start, date_end):
"""AJAX action returning an OS/locale summary."""
Expand All @@ -72,7 +72,7 @@ def demographics(request, date_start, date_end):
return jingo.render(request, 'dashboard/demographics.html', data)


@cache_page()
@cache_page
def messages(request, count=settings.MESSAGES_COUNT):
"""AJAX action returning the most recent messages."""
opinions = Opinion.objects.filter(
Expand Down
2 changes: 1 addition & 1 deletion apps/feedback/views.py
Expand Up @@ -40,7 +40,7 @@ def wrapped(request, *args, **kwargs):

@vary_on_headers('User-Agent')
@enforce_user_agent
@cache_page()
@cache_page
def give_feedback(request, ua, positive):
"""Feedback page (positive or negative)."""

Expand Down
7 changes: 7 additions & 0 deletions apps/input/decorators.py
Expand Up @@ -11,8 +11,15 @@ def cache_page(cache_timeout=None, use_get=False, **kwargs):
Cache an entire page with a cache prefix based on the Site ID and
(optionally) the GET parameters.
"""
# If the first argument is a callable, we've used the decorator without
# args.
if callable(cache_timeout):
f = cache_timeout
return cache_page()(f)

if cache_timeout is None:
cache_timeout = settings.CACHE_DEFAULT_PERIOD

def key_prefix(request):
prefix = '%ss%d:' % (settings.CACHE_PREFIX, settings.SITE_ID)
if use_get:
Expand Down

0 comments on commit 40d19d4

Please sign in to comment.