git.ithinksw.org
/
philo.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added slug to the context for ajax searches.
[philo.git]
/
middleware.py
diff --git
a/middleware.py
b/middleware.py
index
832bd16
..
5ec3e77
100644
(file)
--- a/
middleware.py
+++ b/
middleware.py
@@
-15,17
+15,27
@@
class LazyNode(object):
except Site.DoesNotExist:
current_site = None
except Site.DoesNotExist:
current_site = None
+ path = request._cached_node_path
+ trailing_slash = False
+ if path[-1] == '/':
+ trailing_slash = True
+
try:
try:
- node, subpath = Node.objects.get_with_path(
request._cached_node_
path, root=getattr(current_site, 'root_node', None), absolute_result=False)
+ node, subpath = Node.objects.get_with_path(path, root=getattr(current_site, 'root_node', None), absolute_result=False)
except Node.DoesNotExist:
node = None
except Node.DoesNotExist:
node = None
-
- if subpath is None:
- subpath = ""
- subpath = "/" + subpath
-
- if node:
- node.subpath = subpath
+ else:
+ if subpath is None:
+ subpath = ""
+ subpath = "/" + subpath
+
+ if not node.handles_subpath(subpath):
+ node = None
+ else:
+ if trailing_slash and subpath[-1] != "/":
+ subpath += "/"
+
+ node.subpath = subpath
request._found_node = node
request._found_node = node
@@
-38,7
+48,10
@@
class RequestNodeMiddleware(object):
request.__class__.node = LazyNode()
def process_view(self, request, view_func, view_args, view_kwargs):
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:
def process_exception(self, request, exception):
if settings.DEBUG or not hasattr(request, 'node') or not request.node: