def configure_server_and_app(server_config_file): config = loadJSONFromFileNoPath(server_config_file) #TODO: Validate 'server' in config and load default if not present if 'address' in config['server']: app.config['address'] = config['server']['address'] else: app.config['address'] = 'localhost' if 'port' in config['server']: app.config['port'] = int(config['server']['port']) else: app.config['port'] = 8001 #: Load app config if 'app' in config: if 'modules' in config['app']: app.config['modules'] = config['app']['modules'] else: app.config['modules'] = {'dispatcher': {'module_name': 'cid.core.dispatcher', 'module_route': '/api'}} if 'storage' in config: app.config['storage'] = config['storage'] else: #: TODO: load default storage if not found in config pass if 'debug' in config['server']: app.debug = True if config['server']['debug'] == 'True' else False else: app.debug = False #: TODO: Add a new configuration for session_storage, default volatile dict if 'session_storage' in config: pass else: app.config['session_storage'] = {}
def _register_form_modules_from_path(path, app): config = loadJSONFromFileNoPath(path) for m in config['modules']: try: form = dict() form['name'] = m['module'] module = importlib.import_module(m['package']) path = str(module.__path__[0]) try: form['layout'] = os.path.join(path, m['layout']) except: form['layout'] = None try: form['html'] = os.path.join(path, m['html']) except: form['html'] = None try: form['thumbnail'] = os.path.join(path, m['thumbnail']) except: form['thumbnail'] = None try: form['browsable'] = True if m['browsable'] else False except: form['browsable'] = False form['label'] = m['label'] form['module'] = getattr(module, m['module']) app.caliope_forms[m['module']] = form form['module']() #needed for VersionedNode register except ImportError as e: print m['package'] + '.' + m['module'] app.logger.exception(str(e))
def configure_logger(server_config_file): config = loadJSONFromFileNoPath(server_config_file) from logging.config import dictConfig dictConfig(config)
def configure_server_and_app(server_config_file): config = loadJSONFromFileNoPath(server_config_file) #TODO: Validate 'server' in config and load default if not present if 'address' in config['server']: app.config['address'] = config['server']['address'] else: app.config['address'] = 'localhost' if 'port' in config['server']: app.config['port'] = int(config['server']['port']) else: app.config['port'] = 9000 import os if 'cid_base_directory' in config['server']: app.config['cid_base_directory'] = os.path.join(os.getcwd(), config['server']['cid_base_directory']) else: app.config['cid_base_directory'] = os.path.join(os.getcwd(), "src/cid") if 'static' in config['server']: app.config['STATIC_PATH'] = config['server']['static'] else: app.config['STATIC_PATH'] = "." if 'formTemplates' in config['server']: app.config['FORM_TEMPLATES'] = config['server']['formTemplates'] else: app.config['FORM_TEMPLATES'] = app.config['STATIC_PATH'] if 'formModules' in config['server']: app.config['FORM_MODULES'] = config['server']['formModules'] else: app.config['FORM_MODULES'] = None if 'cache_enabled' in config['server']: app.config['cache_enabled'] = config['server']['cache_enabled'].lower() == 'true' else: app.config['cache_enabled'] = False #: Load app config if 'app' in config: if 'modules' in config['app']: app.config['modules'] = config['app']['modules'] else: app.config['modules'] = {'dispatcher': {'module_name': 'cid.core.dispatcher', 'module_route': '/api'}} if 'storage' in config: app.config['storage'] = config['storage'] else: #: TODO: load default storage if not found in config pass if 'server' in config: app.config['server'] = config['server'] if 'debug' in config['server']: app.debug = config['server']['debug'].lower() == 'true' else: app.debug = False #: TODO: Add a new configuration for session_storage, default volatile dict if 'session_storage' in config: pass else: app.config['session_storage'] = {}
def configure_logger(server_config_file): config = loadJSONFromFileNoPath(server_config_file) from logging.config import dictConfig dictConfig(config)
def configure_server_and_app(server_config_file): config = loadJSONFromFileNoPath(server_config_file) #TODO: Validate 'server' in config and load default if not present if 'address' in config['server']: app.config['address'] = config['server']['address'] else: app.config['address'] = 'localhost' if 'port' in config['server']: app.config['port'] = int(config['server']['port']) else: app.config['port'] = 9000 import os if 'cid_base_directory' in config['server']: app.config['cid_base_directory'] = os.path.join( os.getcwd(), config['server']['cid_base_directory']) else: app.config['cid_base_directory'] = os.path.join(os.getcwd(), "src/cid") if 'static' in config['server']: app.config['STATIC_PATH'] = config['server']['static'] else: app.config['STATIC_PATH'] = "." if 'formTemplates' in config['server']: app.config['FORM_TEMPLATES'] = config['server']['formTemplates'] else: app.config['FORM_TEMPLATES'] = app.config['STATIC_PATH'] if 'formModules' in config['server']: app.config['FORM_MODULES'] = config['server']['formModules'] else: app.config['FORM_MODULES'] = None if 'cache_enabled' in config['server']: app.config['cache_enabled'] = config['server']['cache_enabled'].lower( ) == 'true' else: app.config['cache_enabled'] = False #: Load app config if 'app' in config: if 'modules' in config['app']: app.config['modules'] = config['app']['modules'] else: app.config['modules'] = { 'dispatcher': { 'module_name': 'cid.core.dispatcher', 'module_route': '/api' } } if 'storage' in config: app.config['storage'] = config['storage'] else: #: TODO: load default storage if not found in config pass if 'server' in config: app.config['server'] = config['server'] if 'debug' in config['server']: app.debug = config['server']['debug'].lower() == 'true' else: app.debug = False #: TODO: Add a new configuration for session_storage, default volatile dict if 'session_storage' in config: pass else: app.config['session_storage'] = {}