Esempio n. 1
0
def upgrade_app(install_dir_path, app_symlink_path):
  '''
  Migrates the application's configuration and updates the application symlink.
  '''
  configure.configure_app(
    current_value_install_dir=app_symlink_path,
    output_value_install_dir=install_dir_path
  )

  update_symlink(
    symlink_path=app_symlink_path,
    target_path=install_dir_path
  )
Esempio n. 2
0
def install_app(install_dir_path, app_symlink_path):
  '''
  Installs the application by executing the following process:
  - (0) Check install_dir_path exists and app_symlink_path doesn't
  - (1) Guide user through configuration file changes
  - (2) Initialise the DB, creating users and schema
  - (3) Set up the database schema
  - (4) Executes additional database level tasks (like index creation for improved performance)
  - (5) Symlinks the install directory to the target application directory
  '''
  # (0)
  if not os.path.exists(install_dir_path):
    raise Error(
      'Error:\n' +
      'Install directory path does not exist: "' + install_dir_path + '"'
    )
  if os.path.lexists(app_symlink_path):
    raise Error(
      'Error:\n' +
      'App symlink already exists: "' + app_symlink_path + '"'
    )

  # (1)
  configure.configure_app(
    current_value_install_dir=install_dir_path,
    output_value_install_dir=install_dir_path
  )

  # (2)
  setup_database(
    install_dir_path=install_dir_path
  )

  # (3)
  initialise_schema(
    install_dir_path=install_dir_path
  )

  # (4)
  execute_additional_db_tasks(
    install_dir_path=install_dir_path
  )

  # (5)
  create_app_symlink(
    install_dir_path=install_dir_path,
    app_symlink_path=app_symlink_path
  )
Esempio n. 3
0
def create_app(application=None, default_settings='cajitos_site.settings'):
    application = Flask(__name__, instance_relative_config=True)

    application.config.from_object(default_settings)

    with application.app_context():

        configure_app(application)

    bcrypt.init_app(application)
    login_manager.init_app(application)
    mail.init_app(application)
    moment.init_app(application)
    bootstrap = Bootstrap(application)
    babel.init_app(application)

    if application.config['TESTING']:
        db.initialize(pw.SqliteDatabase(**application.config['DATABASE']))
    else:
        db.initialize(pw.PostgresqlDatabase(**application.config['DATABASE']))
    #  TODO optimize registering blueprints
    from cajitos_site.users.routes import users
    from cajitos_site.bar.routes import bar
    from cajitos_site.blog.routes import blog
    from cajitos_site.misc.routes import misc
    from cajitos_site.errors.routes import errors
    from cajitos_site.service.routes import service
    application.register_blueprint(users)
    application.register_blueprint(blog)
    application.register_blueprint(misc)
    application.register_blueprint(errors)
    application.register_blueprint(service)
    application.register_blueprint(bar)

    # Register models
    from . import models as models
    application.models = models

    application.logger.info('App created')

    return application