Reputation: 101
I have a custom CacheMixin class in wagtail.
class CacheMixin:
def serve(self, request, *args, **kwargs):
response = super().serve(request, *args, **kwargs)
# the rest of the cache implementation
These basically how my custom page models looks like:
class BasePage(CacheMixin, Page):
#some fields
def serve(self, request, *args, **kwargs):
response = super().serve(request, *args, **kwargs)
self._perform_some_ops()
return response
class CustomPage(
RoutablePageMixin,
BasePage,
):
# some fields
@route('my_route/<int:category_id>')
def my_route(self, category_id):
# my route logic
return self.render(
request,
extra_context={
"key1": value_1,
"key2": value_2
},
template="my_app/category.html"
)
The problem is my_route/
is not cached.
If I try to change the orders in the CustomPage class like this: CustomPage(BasePage,RoutablePageMixin)
, the route is not accessible.
I tried overriding the serve method inside the CustomPage
model:
def serve(self, request, *args, **kwargs):
super(RoutablePageMixin, self).serve(request, *args, **kwargs)
return BasePage.serve(self, request, *args, **kwargs)
But again the route is not accessible. What did I miss here? How can I resolve it?
Upvotes: 0
Views: 74
Reputation: 1296
I did something similar by overriding the render method from RoutablePageMixin. Here is a gist of my implementation.
Upvotes: 1