Example #1
0
    def make_config(self, instance_relative=False):
        config = Flask.make_config(self, instance_relative)
        if not config.get('SESSION_COOKIE_NAME'):
            config['SESSION_COOKIE_NAME'] = self.name + '-session'

        # during testing DATA_DIR is not created by instance app, but we still need
        # this attribute to be set
        self.DATA_DIR = Path(self.instance_path, 'data')

        if self._ABILIAN_INIT_TESTING_FLAG:
            # testing: don't load any config file!
            return config

        if instance_relative:
            self.check_instance_folder(create=True)

        cfg_path = os.path.join(config.root_path, 'config.py')
        logger.info('Try to load config: "%s"', cfg_path)
        try:
            config.from_pyfile(cfg_path, silent=False)
        except IOError:
            return config

        config.from_envvar(self.CONFIG_ENVVAR, silent=True)

        if 'WTF_CSRF_ENABLED' not in config:
            config['WTF_CSRF_ENABLED'] = config.get('CSRF_ENABLED', True)

        return config
Example #2
0
  def make_config(self, instance_relative=False):
    config = Flask.make_config(self, instance_relative)
    if not config.get('SESSION_COOKIE_NAME'):
      config['SESSION_COOKIE_NAME'] = self.name + '-session'

    # during testing DATA_DIR is not created by instance app, but we still need
    # this attribute to be set
    self.DATA_DIR = Path(self.instance_path, 'data')

    if self._ABILIAN_INIT_TESTING_FLAG:
      # testing: don't load any config file!
      return config

    if instance_relative:
      self.check_instance_folder(create=True)

    cfg_path = os.path.join(config.root_path, 'config.py')
    logger.info('Try to load config: "%s"', cfg_path)
    try:
      config.from_pyfile(cfg_path, silent=False)
    except IOError:
      return config

    config.from_envvar(self.CONFIG_ENVVAR, silent=True)

    if 'WTF_CSRF_ENABLED' not in config:
      config['WTF_CSRF_ENABLED'] = config.get('CSRF_ENABLED', True)

    return config
Example #3
0
    def make_config(self, instance_relative=False):
        config = Flask.make_config(self, instance_relative)
        if not config.get('SESSION_COOKIE_NAME'):
            config['SESSION_COOKIE_NAME'] = self.name + '-session'

        # during testing DATA_DIR is not created by instance app, but we still need
        # this attribute to be set
        self.DATA_DIR = Path(self.instance_path, 'data')

        if self._ABILIAN_INIT_TESTING_FLAG:
            # testing: don't load any config file!
            return config

        if instance_relative:
            self.check_instance_folder(create=True)

        cfg_path = os.path.join(config.root_path, 'config.py')
        logger.info('Try to load config: "%s"', cfg_path)
        try:
            config.from_pyfile(cfg_path, silent=False)
        except IOError:
            return config

        # If the env var specifies a configuration file, it must exist
        # (and execute with no exceptions) - we don't want the application
        # to run with an unprecised or insecure configuration.
        if self.CONFIG_ENVVAR in os.environ:
            config.from_envvar(self.CONFIG_ENVVAR, silent=False)

        if 'WTF_CSRF_ENABLED' not in config:
            config['WTF_CSRF_ENABLED'] = config.get('CSRF_ENABLED', True)

        return config
Example #4
0
# Since the script has the same name as the module
# we must drop the current path from sys.path:

sys.path.pop(0)
from flaskyll.yamlpages import YamlPages


# Create the Flask application and configure it.
# Re-create the config after overriding root_path
# to be able to use relative paths:

app = Flask(__name__)
app.root_path = os.getcwd()

app.config = app.make_config()
app.config.update({
    'DEBUG': True,
    'PORT': 8000,

    'FREEZER_DESTINATION': 'build',
    'FREEZER_REMOVE_EXTRA_FILES': True,

    'MARKDOWN_EXTENSIONS': ['codehilite', 'extra'],
    'PRUNNING': True,
    'VERBOSE': True,
})


# Load the user configuration: