Skip to content

Instantly share code, notes, and snippets.

@atroche
Created June 30, 2011 08:42
Show Gist options
  • Save atroche/1055871 to your computer and use it in GitHub Desktop.
Save atroche/1055871 to your computer and use it in GitHub Desktop.
def get_context_variable(self, name):
"""
Returns a variable from the context passed to the
template. Only works if your version of Flask
has signals support (0.6+) and blinker is installed.
Raises a ContextVariableDoesNotExist exception if does
not exist in context.
:param name: name of variable
"""
if not _is_signals:
raise RuntimeError("Signals not supported")
for template, context in self.templates:
if name in context:
return context[name]
raise ContextVariableDoesNotExist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment