On 30 Jun 2014, at 15:41, Jeffrey Hearn <
cowbe...@gmail.com> wrote:
> So the 'before_serve_page' hook is the public API for overriding serve()? If check_view_restrictions() is using the same hook, what determines precedence? What about overriding get_context() or get_template()? Is before_serve_page going to be the only public API for serving a page?
before_serve_page is one public API for overriding serve(), but not the only one - it's still valid for subclasses of Page to override any of get_context(), get_template(), route() or serve() with their own behaviour, and that's still the preferred approach if the custom behaviour is specific to a particular page type. The advantage of before_serve_page is that it takes effect regardless of page type.
Officially, the order of precedence for hooks isn't specified... in practice, they're run in the order that the wagtail_hooks.py files are imported, which in turn is determined by the ordering in INSTALLED_APPS. I'm tempted to make that the officially documented policy (especially as I've written application code myself that unwittingly relies on that assumption!) - what do you think?
- Matt
> --
> You received this message because you are subscribed to the Google Groups "Wagtail" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
wagtail+u...@googlegroups.com.
> To post to this group, send email to
wag...@googlegroups.com.
> Visit this group at
http://groups.google.com/group/wagtail.
> To view this discussion on the web, visit
https://groups.google.com/d/msgid/wagtail/0c63f8fb-23a4-4642-88b6-12664f77bb37%40googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.