node, subpath = Node.objects.get_with_path(path, root=getattr(current_site, 'root_node', None), absolute_result=False)
except Node.DoesNotExist:
node = None
+ else:
+ if subpath and not node.handles_subpath(subpath):
+ node = None
if node:
if subpath is None:
request.__class__.node = LazyNode()
def process_view(self, request, view_func, view_args, view_kwargs):
- request._cached_node_path = view_kwargs.get('path', '/')
+ try:
+ request._cached_node_path = view_kwargs['path']
+ except KeyError:
+ pass
def process_exception(self, request, exception):
if settings.DEBUG or not hasattr(request, 'node') or not request.node:
urlpatterns = patterns('',
- url(r'^$', node_view, name='philo-root'),
+ url(r'^$', node_view, kwargs={'path': '/'}, name='philo-root'),
url(r'^(?P<path>.*)$', node_view, name='philo-node-by-path')
)
subpath = request.node.subpath
# Explicitly disallow trailing slashes if we are otherwise at a node's url.
- if request.path and request.path != "/" and request.path[-1] == "/" and subpath == "/":
+ if request._cached_node_path != "/" and request._cached_node_path[-1] == "/" and subpath == "/":
return HttpResponseRedirect(node.get_absolute_url())
if not node.handles_subpath(subpath):