Exemplo n.º 1
0
import sys, os.path, importlib
from flask import Flask
from app import hooks

sys.path.append(os.path.dirname(__file__))
sys.path.append(os.path.dirname(os.path.dirname(__file__)))
import config

app = Flask(__name__)

for module_name in config.MODULES:
    try:
        module = importlib.import_module(module_name)
        hooks.run("module_imported", module_name)
        
        try: # If the module has controllers, we want them
            mod_controllers = importlib.import_module(module_name + ".controllers")
            try:
                app.register_blueprint(mod_controllers.blueprint)
            except AttributeError:
                print("Module " + module_name + " has a 'controllers' submodule, but no blueprint!")

        except ImportError:
            pass

    except ImportError:
        print("Can't import module " + module_name + "!")


hooks.run("startup")
Exemplo n.º 2
0
 def test_hook5(self):
     self.assertIsNone(hooks.run("hook_test_missing"))
Exemplo n.º 3
0
import sys, os.path, importlib
from flask import Flask
from app import hooks

sys.path.append(os.path.dirname(__file__))
sys.path.append(os.path.dirname(os.path.dirname(__file__)))
import config

app = Flask(__name__)

for module_name in config.MODULES:
    try:
        module = importlib.import_module(module_name)
        hooks.run("module_imported", module_name)

        try:  # If the module has controllers, we want them
            mod_controllers = importlib.import_module(module_name +
                                                      ".controllers")
            try:
                app.register_blueprint(mod_controllers.blueprint)
            except AttributeError:
                print("Module " + module_name +
                      " has a 'controllers' submodule, but no blueprint!")

        except ImportError:
            pass

    except ImportError:
        print("Can't import module " + module_name + "!")

hooks.run("startup")
Exemplo n.º 4
0
 def test_hook3(self):
     self.assertTrue(hooks.run("hook_test3"))
Exemplo n.º 5
0
 def test_hook4(self):
     self.assertTrue(hooks.run("hook_test4"))
Exemplo n.º 6
0
 def test_hook1(self):
     self.assertTrue(hooks.run("hook_test1"))
Exemplo n.º 7
0
 def test_hook2(self):
     self.assertTrue(
         hooks.run("hook_test2", "arg1", arg2="arg2", arg3="arg3"))
Exemplo n.º 8
0
 def test_hook5(self):
     self.assertIsNone(hooks.run("hook_test_missing"))
Exemplo n.º 9
0
 def test_hook4(self):
     self.assertTrue(hooks.run("hook_test4"))
Exemplo n.º 10
0
 def test_hook3(self):
     self.assertTrue(hooks.run("hook_test3"))
Exemplo n.º 11
0
 def test_hook2(self):
     self.assertTrue(hooks.run("hook_test2", "arg1", arg2="arg2", arg3="arg3"))
Exemplo n.º 12
0
 def test_hook1(self):
     self.assertTrue(hooks.run("hook_test1"))