#NEWLINE# @ vary_on_headers ( 'Accept' ) #NEWLINE# def node_view( request , path = None , **kwargs ) : #NEWLINE# #INDENT# "\n\t:func:`node_view` handles incoming requests by checking to make sure that:\n\t\n\t- the request has an attached :class:`.Node`.\n\t- the attached :class:`~philo.models.nodes.Node` handles any remaining path beyond its location.\n\t\n\tIf these conditions are not met, then :func:`node_view` will either raise :exc:`Http404` or, if it seems like the address was mistyped (for example missing a trailing slash), return an :class:`HttpResponseRedirect` to the correct address.\n\t\n\tOtherwise, :func:`node_view` will call the :class:`.Node`'s :meth:`~.Node.render_to_response` method, passing ``kwargs`` in as the ``extra_context``.\n\t\n\t" #NEWLINE# if ( 'philo.middleware.RequestNodeMiddleware' not in settings . MIDDLEWARE_CLASSES ) : #NEWLINE# #INDENT# raise MIDDLEWARE_NOT_CONFIGURED #NEWLINE# #UNINDENT# if ( not request . node ) : #NEWLINE# #INDENT# if ( settings . APPEND_SLASH and ( request . path != '/' ) ) : #NEWLINE# #INDENT# path = request . path #NEWLINE# if ( path [ ( - 1 ) ] == '/' ) : #NEWLINE# #INDENT# path = path [ : ( - 1 ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# path += '/' #NEWLINE# #UNINDENT# ( view , args , kwargs ) = resolve ( path ) #NEWLINE# if ( view != node_view ) : #NEWLINE# #INDENT# return HttpResponseRedirect ( path ) #NEWLINE# #UNINDENT# #UNINDENT# raise Http404 #NEWLINE# #UNINDENT# node = request . node #NEWLINE# subpath = request . node . _subpath #NEWLINE# if ( ( node . _path != '/' ) and ( node . _path [ ( - 1 ) ] == '/' ) and ( subpath == '/' ) ) : #NEWLINE# #INDENT# return HttpResponseRedirect ( node . get_absolute_url ( ) ) #NEWLINE# #UNINDENT# if ( not node . handles_subpath ( subpath ) ) : #NEWLINE# #INDENT# if ( not settings . APPEND_SLASH ) : #NEWLINE# #INDENT# raise Http404 #NEWLINE# #UNINDENT# if ( subpath [ ( - 1 ) ] == '/' ) : #NEWLINE# #INDENT# subpath = subpath [ : ( - 1 ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# subpath += '/' #NEWLINE# #UNINDENT# redirect_url = node . construct_url ( subpath ) #NEWLINE# if node . handles_subpath ( subpath ) : #NEWLINE# #INDENT# return HttpResponseRedirect ( redirect_url ) #NEWLINE# #UNINDENT# ( view , args , kwargs ) = resolve ( redirect_url ) #NEWLINE# if ( view == node_view ) : #NEWLINE# #INDENT# raise Http404 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return HttpResponseRedirect ( redirect_url ) #NEWLINE# #UNINDENT# #UNINDENT# return node . render_to_response ( request , kwargs )