Fail elegantly when resolving a menu and there is no request variable.

This commit is contained in:
Roberto Rosario
2015-10-09 23:39:56 -04:00
parent 36805b3540
commit d4d9a5a276

View File

@@ -91,7 +91,14 @@ class Menu(object):
)
def resolve(self, context, source=None):
try:
request = Variable('request').resolve(context)
except VariableDoesNotExist:
# There is no request variable, most probable a 500 in a test view
# Don't return any resolved links then.
logger.warning('No request variable, aborting menu resolution')
return ()
current_path = request.META['PATH_INFO']
# Get sources: view name, view objects