From e5d66d3ef89b354d37e5efe68281fd4d35f61969 Mon Sep 17 00:00:00 2001 From: George Hickman Date: Tue, 2 Apr 2013 14:21:19 +0100 Subject: [PATCH] Add public facing methods to BaseCacheLookup There seems little point in using BaseCacheLookup by default so it can act as an example to implementing classes. --- rest_framework/cache_lookups.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/rest_framework/cache_lookups.py b/rest_framework/cache_lookups.py index eb314ca42..8ee96e197 100644 --- a/rest_framework/cache_lookups.py +++ b/rest_framework/cache_lookups.py @@ -2,18 +2,25 @@ Provides a set of pluggable cache policies. """ from django.core.cache import cache +from django.core.exceptions import ImproperlyConfigured from rest_framework.exceptions import PreconditionFailed class BaseCacheLookup(object): - def get_header(self, obj): - return {} + def get_request_header(self): + raise ImproperlyConfigured('Subclass must implement `get_request_header`.') + + def get_update_header(self): + raise ImproperlyConfigured('Subclass must implement `get_update_header`.') + + def get_response_header(self, obj): + raise ImproperlyConfigured('Subclass must impelement `get_response_header`.') + + def precondition_check(self, obj, request): + raise ImproperlyConfigured('Subclass must implement `precondition_check`.') def resource_unchanged(self, request): - """ - Return `False` if resource has changed, `True` otherwise. - """ - return False + raise ImproperlyConfigured('Subclass must implement `resource_unchanged`.') class ETagCacheLookup(BaseCacheLookup):