コード例 #1
0
def test_repr_state(flask_app, loaded_engine):
    """
    Check that repr(PluginEngineState(...)) is OK
    """
    from flask_pluginengine.util import get_state
    assert repr(get_state(flask_app)) == ("<_PluginEngineState(<PluginEngine()>, <PluginFlask 'test_engine'>, "
                                          "{'espresso': <EspressoModule(espresso) bound to "
                                          "<PluginFlask 'test_engine'>>})>")
コード例 #2
0
ファイル: templating.py プロジェクト: indico/indico
 def load(self, environment, name, globals=None):
     tpl = super(CustomizationLoader, self).load(environment, name, globals)
     if ':' not in name:
         return tpl
     # This is almost exactly what PluginPrefixLoader.load() does, but we have
     # to replicate it here since we need to handle `~` and use our custom
     # `get_source` to get the overridden template
     plugin_name, tpl_name = name.split(':', 1)
     if plugin_name[0] == '~':
         plugin_name = plugin_name[1:]
     plugin = get_state(current_app).plugin_engine.get_plugin(plugin_name)
     if plugin is None:
         # that should never happen
         raise RuntimeError('Plugin template {} has no plugin'.format(name))
     tpl.plugin = plugin
     return tpl
コード例 #3
0
 def load(self, environment, name, globals=None):
     tpl = super(CustomizationLoader, self).load(environment, name, globals)
     if ':' not in name:
         return tpl
     # This is almost exactly what PluginPrefixLoader.load() does, but we have
     # to replicate it here since we need to handle `~` and use our custom
     # `get_source` to get the overridden template
     plugin_name, tpl_name = name.split(':', 1)
     if plugin_name[0] == '~':
         plugin_name = plugin_name[1:]
     plugin = get_state(current_app).plugin_engine.get_plugin(plugin_name)
     if plugin is None:
         # that should never happen
         raise RuntimeError('Plugin template {} has no plugin'.format(name))
     tpl.plugin = plugin
     return tpl