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

Commit

Permalink
Adding http_cache parameter to @viewconfig functions with default val…
Browse files Browse the repository at this point in the history
…ue equal to zero
  • Loading branch information
rich-hart committed Mar 18, 2015
1 parent 18f94c1 commit 1847d78
Showing 1 changed file with 31 additions and 18 deletions.
49 changes: 31 additions & 18 deletions cnxauthoring/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from .storage import storage
from . import utils

NO_CACHE = 0

logger = logging.getLogger('cnxauthoring')

Expand Down Expand Up @@ -81,10 +82,10 @@ def login(request):
if request.unauthenticated_userid:
return httpexceptions.HTTPFound(location=redirect_to)
request.session.update({'redirect_to': redirect_to})
request.authenticated_userid # triggers login
request.authenticated_userid # triggers login


@view_config(route_name='callback')
@view_config(route_name='callback', http_cache=NO_CACHE)
@authenticated_only
def callback(request):
# callback must be protected so that effective_principals is called
Expand All @@ -111,7 +112,8 @@ def options(request):
return ''


@view_config(route_name='user-search', request_method='GET', renderer='json')
@view_config(route_name='user-search', request_method='GET',
renderer='json', http_cache=NO_CACHE)
@authenticated_only
def user_search(request):
"""Search for openstax accounts users"""
Expand All @@ -134,7 +136,8 @@ def user_search(request):
return result


@view_config(route_name='profile', request_method='GET', renderer='json')
@view_config(route_name='profile', request_method='GET',
renderer='json', http_cache=NO_CACHE)
@authenticated_only
def profile(request):
return UserSchema().bind().deserialize(
Expand All @@ -161,7 +164,8 @@ def update_content_state(request, content):
pass


@view_config(route_name='user-contents', request_method='GET', renderer='json')
@view_config(route_name='user-contents', request_method='GET',
renderer='json', http_cache=NO_CACHE)
@authenticated_only
@storage_management
def user_contents(request):
Expand Down Expand Up @@ -222,7 +226,8 @@ def user_contents(request):
}


@view_config(route_name='get-content-json', request_method='GET', renderer='json')
@view_config(route_name='get-content-json', request_method='GET',
renderer='json', http_cache=NO_CACHE)
@authenticated_only
@storage_management
def get_content(request):
Expand All @@ -239,7 +244,8 @@ def get_content(request):
return content


@view_config(route_name='get-resource', request_method='GET')
@view_config(route_name='get-resource', request_method='GET',
http_cache=NO_CACHE)
@authenticated_only
@storage_management
def get_resource(request):
Expand Down Expand Up @@ -370,7 +376,9 @@ def post_content_single(request, cstruct):

return content

@view_config(route_name='post-content', request_method='POST', renderer='json')

@view_config(route_name='post-content', request_method='POST',
renderer='json', http_cache=NO_CACHE)
@authenticated_only
@storage_management
def post_content(request):
Expand Down Expand Up @@ -407,7 +415,8 @@ def post_content(request):
return contents


@view_config(route_name='post-resource', request_method='POST', renderer='string')
@view_config(route_name='post-resource', request_method='POST',
renderer='string', http_cache=NO_CACHE)
@authenticated_only
@storage_management
def post_resource(request):
Expand Down Expand Up @@ -482,13 +491,12 @@ def delete_content_single(request, id, user_id=None, raise_error=True):
return True



@view_config(route_name='delete-user-content', request_method='DELETE',
renderer='json')
renderer='json', http_cache=NO_CACHE)
@view_config(route_name='delete-content', request_method='DELETE',
renderer='json')
renderer='json', http_cache=NO_CACHE)
@view_config(route_name='delete-content-multiple', request_method='PUT',
renderer='json')
renderer='json', http_cache=NO_CACHE)
@authenticated_only
@storage_management
def delete_content(request):
Expand All @@ -515,7 +523,9 @@ def delete_content(request):
user_id = request.authenticated_userid
delete_content_single(request, id, user_id=user_id)

@view_config(route_name='put-content', request_method='PUT', renderer='json')

@view_config(route_name='put-content', request_method='PUT',
renderer='json', http_cache=NO_CACHE)
@authenticated_only
@storage_management
def put_content(request):
Expand Down Expand Up @@ -572,7 +582,8 @@ def put_content(request):
return content


@view_config(route_name='search-content', request_method='GET', renderer='json')
@view_config(route_name='search-content', request_method='GET',
renderer='json', http_cache=NO_CACHE)
@authenticated_only
@storage_management
def search_content(request):
Expand Down Expand Up @@ -661,7 +672,8 @@ def post_to_publishing(request, userid, submitlog, content_ids):
return contents, requests.post(url, files=files, headers=headers)


@view_config(route_name='publish', request_method='POST', renderer='json')
@view_config(route_name='publish', request_method='POST',
renderer='json', http_cache=NO_CACHE)
@authenticated_only
@storage_management
def publish(request):
Expand Down Expand Up @@ -698,7 +710,7 @@ def publish(request):


@view_config(route_name='acceptance-info', request_method='GET',
renderer='json')
renderer='json', http_cache=NO_CACHE)
@authenticated_only
@storage_management
def get_acceptance_info(request):
Expand Down Expand Up @@ -747,7 +759,8 @@ def get_acceptance_info(request):
return info


@view_config(route_name='acceptance-info', request_method=('POST', 'PUT'))
@view_config(route_name='acceptance-info',
request_method=('POST', 'PUT'), http_cache=NO_CACHE)
@authenticated_only
@storage_management
def post_acceptance_info(request):
Expand Down

0 comments on commit 1847d78

Please sign in to comment.