Last active
August 29, 2015 13:57
-
-
Save kaedroho/9485353 to your computer and use it in GitHub Desktop.
Routing change
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def route_self(self, request, path_components): | |
""" | |
Override this if you want to use custom routing | |
""" | |
if path_components: | |
# path_components has been set but this page doesn't use custom routing | |
raise Http404 | |
else: | |
return self.serve(request) | |
def route(self, request, path_components): | |
if self.live: | |
try: | |
return self.route_self(request, path_components) | |
except Http404: | |
pass | |
if path_components: | |
# request is for a child of this page | |
child_slug = path_components[0] | |
remaining_components = path_components[1:] | |
subpage = self.get_children().get(slug=child_slug) | |
return subpage.specific.route(request, remaining_components) | |
else: | |
raise Http404 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment