Created
June 30, 2011 08:42
-
-
Save atroche/1055872 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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