Skip to content

Commit

Permalink
Handle Resolver404 exception in context processors
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelm committed Feb 17, 2016
1 parent ba678de commit 72e6680
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/pretix/control/context.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.conf import settings
from django.core.urlresolvers import get_script_prefix, resolve
from django.core.urlresolvers import Resolver404, get_script_prefix, resolve

from .signals import html_head, nav_event

Expand All @@ -8,7 +8,11 @@ def contextprocessor(request):
"""
Adds data to all template contexts
"""
url = resolve(request.path_info)
try:
url = resolve(request.path_info)
except Resolver404:
return {}

if not request.path.startswith(get_script_prefix() + 'control'):
return {}
ctx = {
Expand Down
7 changes: 5 additions & 2 deletions src/pretix/presale/context.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.core.urlresolvers import resolve
from django.core.urlresolvers import Resolver404, resolve

from .signals import html_head

Expand All @@ -7,7 +7,10 @@ def contextprocessor(request):
"""
Adds data to all template contexts
"""
url = resolve(request.path_info)
try:
url = resolve(request.path_info)
except Resolver404:
return {}
if url.namespace != 'presale':
return {}

Expand Down

0 comments on commit 72e6680

Please sign in to comment.