Example #1
0
def build_manager():
    manager = Manager(app)
    # ADD DB COMMAND
    manager.add_command('db', MigrateCommand)
    migrate = Migrate(app, db)

    # ADD SHELL COMMANDS
    def _make_context():
        return dict(app=app, db=db, Member=Member, use_ipython=False)
    manager.add_command('shell', Shell(make_context=_make_context))

    # TEST
    @manager.command
    def hello():
        print "hello"

    # init Alchemy Dumps (local db table backups)
    alchemydumps = AlchemyDumps(app, db)
    manager.add_command('alchemydumps', AlchemyDumpsCommand)
    return manager
Example #2
0
import os

from flask_alchemydumps import AlchemyDumps, AlchemyDumpsCommand
from flask_migrate import Migrate, MigrateCommand
from flask_script import Manager

from app import app, db

app.config.from_object(os.environ['APP_SETTINGS'])
manager = Manager(app)


migrate = Migrate(app, db)
manager.add_command('db', MigrateCommand)

# init Alchemy Dumps
alchemydumps = AlchemyDumps(app, db)
manager.add_command('alchemydumps', AlchemyDumpsCommand)


if __name__ == '__main__':
    manager.run()
Example #3
0
from flask_babel import Babel
from flask_bcrypt import Bcrypt
from flask.ext.uploads import UploadSet, IMAGES
from celery import Celery
from flask_mail import Mail
from flask_s3 import FlaskS3
from flask_wtf.csrf import CsrfProtect

from slugify import slugify
from babel import Locale, UnknownLocaleError
import yaml
import locale

s3 = FlaskS3()
mail = Mail()
alchemydumps = AlchemyDumps()
security = Security()
csrf = CsrfProtect()
babel = Babel()
bcrypt = Bcrypt()

celery = Celery(
    __name__,
    broker='redis://redis',  #TODO this should be from config
    include=['app.tasks'])

assets = Environment()

main_css = Bundle('css/vendor/bootstrap.css',
                  output='gen/main_packed.%(version)s.css')
assets.register('main_css', main_css)
Example #4
0
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.script import Manager
from flask_alchemydumps import AlchemyDumps, AlchemyDumpsCommand

# create a Flask app
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///test.db'
ftp_settings = ['ALCHEMYDUMPS_FTP_SERVER',
                'ALCHEMYDUMPS_FTP_USER',
                'ALCHEMYDUMPS_FTP_PASSWORD',
                'ALCHEMYDUMPS_FTP_PATH']
for setting in ftp_settings:
    app.config[setting] = config(setting, default=False)
db = SQLAlchemy(app)
manager = Manager(app)
alchemydumps = AlchemyDumps(app, db, basedir='tests/')
manager.add_command('alchemydumps', AlchemyDumpsCommand)


# create models
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String(140), index=True, unique=True)
    posts = db.relationship('Post', backref='author', lazy='dynamic')


class Post(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(140))
    content = db.Column(db.UnicodeText)
    author_id = db.Column(db.Integer, db.ForeignKey('user.id'))