Exemplo n.º 1
0
    if bp.url_prefix == '/' or not bp.url_prefix:
        exit("Blueprint %s tried to assert itself as the root path ('/')")

    app.register_blueprint(bp, url_prefix=getattr(bp, 'prefix', None))

def append_to_navigation_menu(dictionary):
    navigation_dictionary_list.append(dictionary)


@app.context_processor
def inject_site_name():
    return dict(site_name=APP.SITE_NAME)


@app.context_processor
def inject_navbar(navigation_dict=navigation_dictionary_list):
    return dict(navbar_items=navigation_dict)

# Load the version of core specified by the user to pin
try:
    __import__("yams_api.core.%s" % APP.API_VERSION_CORE)
except ImportError as e:
    logfile.critical("Failed to load core version: %s" % e)
    exit(1)


@app.route('/')
def index():
    return render_template("index.html")
Exemplo n.º 2
0
        exit("Blueprint %s tried to assert itself as the root path ('/')")

    app.register_blueprint(bp, url_prefix=getattr(bp, 'prefix', None))


def append_to_navigation_menu(dictionary):
    navigation_dictionary_list.append(dictionary)


@app.context_processor
def inject_site_name():
    return dict(site_name=APP.SITE_NAME)


@app.context_processor
def inject_navbar(navigation_dict=navigation_dictionary_list):
    return dict(navbar_items=navigation_dict)


# Load the version of core specified by the user to pin
try:
    __import__("yams_api.core.%s" % APP.API_VERSION_CORE)
except ImportError as e:
    logfile.critical("Failed to load core version: %s" % e)
    exit(1)


@app.route('/')
def index():
    return render_template("index.html")
Exemplo n.º 3
0
from importlib.machinery import SourceFileLoader

_here = os.path.abspath(os.path.dirname(__file__))
plugins = glob.glob(_here + "/*/views.py")

for _p in plugins:
    try:
        _plug_dirname = os.path.split(os.path.split(_p)[0])[1]

        # This is ugly: __import__("yams_api.dev.plugins.%s.views" % (_plug_dirname))
        _mod_name = "%s.views" % _plug_dirname
        s = SourceFileLoader(_mod_name, _p).load_module()

    except ImportError as e:
        logfile.critical("Failed to import module: %s :: %s" % (_p, e))


# error handling and request behavior
@dev_bp.errorhandler(ValidationError)
def validation_error(e):
    return bad_request(e.args[0])


@dev_bp.errorhandler(400)
def bad_request_error(e):
    return bad_request("invalid request")


@dev_bp.errorhandler(404)
def not_found_error(e):
Exemplo n.º 4
0
from importlib.machinery import SourceFileLoader

_here = os.path.abspath(os.path.dirname(__file__))
plugins = glob.glob(_here + "/*/views.py")

for _p in plugins:
    try:
        _plug_dirname = os.path.split(os.path.split(_p)[0])[1]

        # This is ugly: __import__("yams_api.dev.plugins.%s.views" % (_plug_dirname))
        _mod_name = "%s.views" % _plug_dirname
        s = SourceFileLoader(_mod_name, _p).load_module()

    except ImportError as e:
        logfile.critical("Failed to import module: %s :: %s" % (_p, e))


# error handling and request behavior
@dev_bp.errorhandler(ValidationError)
def validation_error(e):
    return bad_request(e.args[0])


@dev_bp.errorhandler(400)
def bad_request_error(e):
    return bad_request("invalid request")


@dev_bp.errorhandler(404)
def not_found_error(e):