edoburu/django-fluent-pages — pull request #22 by borgstrom (2013-04-03 18:47:54+00:00)
Title: Modify _get_current_page to handle an invalid 'page' in context

In the project we're currently building out with django-fluent-pages we have a global footer that renders menus from our pages. We use `get_fluent_page_vars` in our template to ensure that the 'page' & 'site' variables are always in context.

We just recently integrated haystack searching into the site and ran into a problem when accessing the search results. The exception we received was:

'Page' object has no attribute 'parent_site'

This is because haystack uses its own variable named 'page' in the context that it uses for pagination. When our call to `get_fluent_page_vars` happened it saw the existing page variable and thus just blindly used it.

This change ensures that the object being assigned to `request._current_fluent_page` is actually a `UrlNode` object, and if not then it will try to look it up using the request path and fall back to a dummy page exactly the same as it does elsewhere in the template tags.