- Change Summary:
-
Adding the appropriate review group.
- Groups:
Allow TemplateHook to be selective based on URL name
Review Request #1629 — Created May 31, 2010 and submitted
TemplateHook currently allows extensions to insert templates into our Django app. So, for example, we have a hook called "base-scripts-post" which inserts templates on the base template. Now, while creating a TemplateHook, we can supply an optional apply_to list parameter which allows us to specify which view functions should really render the hook. For example: TemplateHook(self, "base-scripts-post", "rbstats/rbstats_dlgs.html", ["dashboard"]) Now rbstats_dlgs.html will only be rendered on the dashboard view function. I'm not entirely sure if my way of finding "func_name" is the way to go. Open to suggestions.
Manual.
- Change Summary:
-
This patch relies on http://reviews.reviewboard.org/r/1674/ Ok, found a solution to this problem. I've written a tiny Middleware to stash kwargs into the request META. This, coupled with the URL name, allows us to use "reverse" to determine what the current URL should be. If it *is* the current URL, then we should render the TemplateHook.
- Change Summary:
-
Originally, I caught a NoReverseMatch exception if the URL didn't take kwargs. I forgot to catch the *other* exception, in the event that there's no match even without the kwargs.