stephenmcd/mezzanine — pull request #270 by AlexHill (2012-06-14 07:09:35+00:00)
Title: A few minor fixes in PageMiddleware

I've refactored PageMiddleware slightly to achieve the following:

* Use only one database query to match the nearest page by using a slug__in filter on the page QuerySet.
* /private/nonexistentpage/, where /private/ requires login and /private/nonexistentpage/ doesn't exist, will now show a login prompt for unauthenticated users, rather than a 404. This is consistent with the behaviour for apps mounted in the page tree.
* Return as early as possible when no page can be matched to the slug or a sub-slug, or when authentication is required.
* Only check for the context_data attribute once.

Cheers,
Alex