Handling Requests

philo.middleware.get_node(path)

Returns a Node instance at path (relative to the current site) or None.

class philo.middleware.RequestNodeMiddleware

Adds a node attribute, representing the currently-viewed Node, to every incoming HttpRequest object. This is required by philo.views.node_view().

RequestNodeMiddleware also catches all exceptions raised while handling requests that have attached Nodes if settings.DEBUG is True. If a django.http.Http404 error was caught, RequestNodeMiddleware will look for an “Http404” Attribute on the request’s Node; otherwise it will look for an “Http500” Attribute. If an appropriate Attribute is found, and the value of the attribute is a View instance, then the View will be rendered with the exception in the extra_context, bypassing any later handling of exceptions.

philo.views.node_view(request[, path=None, **kwargs])

node_view() handles incoming requests by checking to make sure that:

  • the request has an attached Node.
  • the attached Node handles any remaining path beyond its location.

If these conditions are not met, then node_view() will either raise Http404 or, if it seems like the address was mistyped (for example missing a trailing slash), return an HttpResponseRedirect to the correct address.

Otherwise, node_view() will call the Node‘s render_to_response() method, passing kwargs in as the extra_context.

Project Versions

Previous topic

Exceptions

Next topic

Signals

This Page