Beispiel #1
0
 def dispatch(self, *args, **kwargs):
     # Use lambda to bound self and to avoid passing request, *args, **kwargs as the decorator would do
     # TODO: we should be storing cache_latest and cache_latest_dispatch for reuse
     # but it triggers other problems (self.cache_latest() - will pass self as an unwanted arg)
     cache_latest = cache_last_modified(lambda x: self.model.latest_updated())
     cache_latest_dispatch = cache_latest(super(MapEntityLayer, self).dispatch)
     return cache_latest_dispatch(*args, **kwargs)
Beispiel #2
0
        def _wrapped_view(self, request, *args, **kwargs):
            view_model = self.get_model()

            cache_latest = cache_last_modified(
                lambda x: view_model.latest_updated())
            cbv_cache_latest = method_decorator(cache_latest)

            @method_decorator(cache_control(max_age=0, must_revalidate=True))
            @cbv_cache_latest
            def decorated(self, request, *args, **kwargs):
                return view_func(self, request, *args, **kwargs)

            return decorated(self, request, *args, **kwargs)
        def _wrapped_view(self, request, *args, **kwargs):
            view_model = self.get_model()

            cache_latest = cache_last_modified(lambda x: view_model.latest_updated())
            cbv_cache_latest = method_decorator(cache_latest)

            # The first decorator forces browser's cache revalidation.
            # The second one allows browser's cache revalidation.
            @method_decorator(never_cache)
            @cbv_cache_latest
            def decorated(self, request, *args, **kwargs):
                return view_func(self, request, *args, **kwargs)

            return decorated(self, request, *args, **kwargs)
        def _wrapped_view(self, request, *args, **kwargs):
            view_model = self.get_model()

            cache_latest = cache_last_modified(
                lambda x: view_model.latest_updated())
            cbv_cache_latest = method_decorator(cache_latest)

            # The first decorator forces browser's cache revalidation.
            # The second one allows browser's cache revalidation.
            @method_decorator(never_cache)
            @cbv_cache_latest
            def decorated(self, request, *args, **kwargs):
                return view_func(self, request, *args, **kwargs)

            return decorated(self, request, *args, **kwargs)