Пример #1
0
def __load_config(path=None):
    #Strategy:
    # 1) Load the default config
    # 2) Load the filters and controllers
    # 3) Finally load the user's config.
    # This will ensure that we have good default values if the user's
    # config is missing something.
    exec(default_config)
    filter.preload_filters()
    controller.load_controllers()
    if path:
        execfile(path)
    #config is now in locals() but needs to be in globals()
    for k, v in locals().items():
        globals()[k] = v
    #Override any options (from unit tests)
    for k, v in override_options.items():
        if "." in k:
            parts = k.split(".")
            cache_object = ".".join(parts[:-1])
            setting = parts[-1]
            cache_object = eval(cache_object)
            cache_object[setting] = v
        else:
            globals()[k] = v
    recompile()
    __loaded = True
Пример #2
0
def __load_config(path=None):
    #Strategy:
    # 1) Load the default config
    # 2) Load the filters and controllers
    # 3) Finally load the user's config.
    # This will ensure that we have good default values if the user's
    # config is missing something.
    exec(default_config)
    filter.preload_filters()
    controller.load_controllers()
    if path:
        execfile(path)
    #config is now in locals() but needs to be in globals()
    for k, v in locals().items():
        globals()[k] = v
    #Override any options (from unit tests)
    for k, v in override_options.items():
        if "." in k:
            parts = k.split(".")
            cache_object = ".".join(parts[:-1])
            setting = parts[-1]
            cache_object = eval(cache_object)
            cache_object[setting] = v
        else:
            globals()[k] = v
    recompile()
    __loaded = True
Пример #3
0
def load_plugins():
    """Discover all the installed plugins and load them into bf.config.plugins

    Load the module itself, the controllers, and the filters"""
    for plugin in iter_plugins():
        namespace = bf.config.plugins[plugin.__dist__["config_name"]] = \
            getattr(plugin,"config")
        check_plugin_config(plugin)
        namespace.mod = plugin
        plugin_dir = os.path.dirname(sys.modules[plugin.__name__].__file__)
        #TODO: Load filters
        plugin.filters = HierarchicalCache()
        #Load controllers
        controller.load_controllers(
            namespace=namespace.controllers,
            directory=os.path.join(plugin_dir,"site_src","_controllers"),
            defaults={"enabled":True})
Пример #4
0
def load_plugins():
    """Discover all the installed plugins and load them into bf.config.plugins

    Load the module itself, the controllers, and the filters"""
    for plugin in iter_plugins():
        namespace = bf.config.plugins[plugin.__dist__["config_name"]] = \
            getattr(plugin,"config")
        check_plugin_config(plugin)
        namespace.mod = plugin
        plugin_dir = os.path.dirname(sys.modules[plugin.__name__].__file__)
        #TODO: Load filters
        plugin.filters = HierarchicalCache()
        #Load controllers
        controller.load_controllers(namespace=namespace.controllers,
                                    directory=os.path.join(
                                        plugin_dir, "site_src",
                                        "_controllers"),
                                    defaults={"enabled": True})