-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3425976
Showing
52 changed files
with
1,242 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
*.py[co] | ||
__pycache__ | ||
|
||
# Translations compiled files | ||
*.mo | ||
|
||
# Local development ignores | ||
venv | ||
data.sqlite | ||
|
||
# Production config | ||
local.cfg | ||
|
||
# Static | ||
static/libs/* | ||
|
||
# Other stuff here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Fresh installation test | ||
# | ||
# To run this: sudo docker build . | ||
|
||
FROM stackbrew/ubuntu:saucy | ||
MAINTAINER Flask developers | ||
|
||
RUN apt-get update | ||
|
||
ADD ./ /code/ | ||
|
||
ENV DEBIAN_FRONTEND noninteractive | ||
RUN cat /code/packages.txt | xargs apt-get -y --force-yes install | ||
RUN npm install -g bower | ||
RUN ldconfig | ||
|
||
RUN cd /code/ && make setup | ||
|
||
RUN cd /code/src/ && python manage.py test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
all: setup | ||
|
||
venv/bin/activate: | ||
virtualenv-2.7 venv | ||
|
||
run: venv/bin/activate requirements.txt | ||
. venv/bin/activate; python manage.py runserver | ||
|
||
static/bower.json: | ||
cd static && bower install | ||
|
||
setup: venv/bin/activate requirements.txt static/bower.json | ||
. venv/bin/activate; pip install -Ur requirements.txt | ||
|
||
init: venv/bin/activate requirements.txt | ||
. venv/bin/activate; python manage.py init | ||
|
||
babel: venv/bin/activate | ||
. venv/bin/activate; pybabel extract -F babel.cfg -o project/translations/messages.pot project | ||
|
||
# lazy babel scan | ||
lazybabel: venv/bin/activate | ||
. venv/bin/activate; pybabel extract -F babel.cfg -k lazy_gettext -o project/translations/messages.pot project | ||
|
||
# run $LANG=ru | ||
addlang: venv/bin/activate | ||
. venv/bin/activate; pybabel init -i project/translations/messages.pot -d project/translations -l $(LANG) | ||
|
||
updlang: venv/bin/activate | ||
. venv/bin/activate; pybabel update -i project/translations/messages.pot -d project/translations |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Flask project template | ||
|
||
Flask project template. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[python: **.py] | ||
[jinja2: **.html] | ||
extensions=jinja2.ext.autoescape,jinja2.ext.with_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# production mode, yopta | ||
DEBUG = False | ||
|
||
SQLALCHEMY_ECHO = True | ||
SQLALCHEMY_RECORD_QUERIES = False | ||
|
||
# this is example deployment configuration | ||
|
||
# run python and execute this code | ||
# >>> import os; os.urandom(24) | ||
# value place here as result | ||
|
||
# SECRET_KEY = '<key>' | ||
|
||
# BROKER_URL = "mongodb://localhost" | ||
# CELERY_RESULT_BACKEND = 'mongodb' | ||
# CELERY_IMPORTS = ('backend.tasks',) | ||
# CELERY_MONGODB_BACKEND_SETTINGS = { | ||
# 'host': 'localhost', | ||
# 'port': 27017, | ||
# 'database': 'digdata_celery', | ||
# #'user': user, | ||
# #'password': password, | ||
# 'taskmeta_collection': 'teskmeta' | ||
# } | ||
# CELERY_ANNOTATIONS = {"*": {"rate_limit": "10/s"}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
from flask import json | ||
|
||
from flask.ext.script import Manager | ||
from flask.ext.migrate import MigrateCommand | ||
|
||
from project import create_app | ||
from project.extensions import db | ||
|
||
from sqlalchemy.exc import OperationalError | ||
from sqlalchemy.ext.serializer import dumps, loads | ||
|
||
manager = Manager(create_app) | ||
# Add Flask-Migrate commands under `db` prefix, for example: | ||
# $ python manage.py db init | ||
# | ||
# $ python manage.py db migrate | ||
# | ||
|
||
manager.add_command('db', MigrateCommand) | ||
|
||
|
||
@manager.command | ||
def init(): | ||
"""Run in local machine.""" | ||
syncdb() | ||
|
||
|
||
@manager.command | ||
def syncdb(): | ||
"""Init/reset database.""" | ||
db.drop_all() | ||
db.create_all() | ||
|
||
|
||
manager.add_option('-c', '--config', dest="config", required=False, | ||
help="config file") | ||
|
||
if __name__ == "__main__": | ||
manager.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Generic single-database configuration. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# A generic, single database configuration. | ||
|
||
[alembic] | ||
# template used to generate migration files | ||
# file_template = %%(rev)s_%%(slug)s | ||
|
||
# set to 'true' to run the environment during | ||
# the 'revision' command, regardless of autogenerate | ||
# revision_environment = false | ||
|
||
|
||
# Logging configuration | ||
[loggers] | ||
keys = root,sqlalchemy,alembic | ||
|
||
[handlers] | ||
keys = console | ||
|
||
[formatters] | ||
keys = generic | ||
|
||
[logger_root] | ||
level = WARN | ||
handlers = console | ||
qualname = | ||
|
||
[logger_sqlalchemy] | ||
level = WARN | ||
handlers = | ||
qualname = sqlalchemy.engine | ||
|
||
[logger_alembic] | ||
level = INFO | ||
handlers = | ||
qualname = alembic | ||
|
||
[handler_console] | ||
class = StreamHandler | ||
args = (sys.stderr,) | ||
level = NOTSET | ||
formatter = generic | ||
|
||
[formatter_generic] | ||
format = %(levelname)-5.5s [%(name)s] %(message)s | ||
datefmt = %H:%M:%S | ||
|
||
[alembic:exclude] | ||
tables = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
from __future__ import with_statement | ||
from alembic import context | ||
from sqlalchemy import engine_from_config, pool | ||
from logging.config import fileConfig | ||
|
||
# this is the Alembic Config object, which provides | ||
# access to the values within the .ini file in use. | ||
config = context.config | ||
|
||
# Interpret the config file for Python logging. | ||
# This line sets up loggers basically. | ||
fileConfig(config.config_file_name) | ||
|
||
# add your model's MetaData object here | ||
# for 'autogenerate' support | ||
# from myapp import mymodel | ||
# target_metadata = mymodel.Base.metadata | ||
from flask import current_app | ||
config.set_main_option('sqlalchemy.url', current_app.config.get('SQLALCHEMY_DATABASE_URI')) | ||
target_metadata = current_app.extensions['migrate'].db.metadata | ||
|
||
# other values from the config, defined by the needs of env.py, | ||
# can be acquired: | ||
# my_important_option = config.get_main_option("my_important_option") | ||
# ... etc. | ||
|
||
|
||
def exclude_tables_from_config(config_): | ||
tables_ = config_.get("tables", None) | ||
if tables_ is not None: | ||
tables = tables_.split(",") | ||
return tables | ||
|
||
exclude_tables = exclude_tables_from_config(config.get_section('alembic:exclude')) | ||
|
||
|
||
def include_object(object, name, type_, reflected, compare_to): | ||
if type_ == "table" and name in exclude_tables: | ||
return False | ||
else: | ||
return True | ||
|
||
|
||
def run_migrations_offline(): | ||
"""Run migrations in 'offline' mode. | ||
This configures the context with just a URL | ||
and not an Engine, though an Engine is acceptable | ||
here as well. By skipping the Engine creation | ||
we don't even need a DBAPI to be available. | ||
Calls to context.execute() here emit the given string to the | ||
script output. | ||
""" | ||
url = config.get_main_option("sqlalchemy.url") | ||
context.configure(url=url) | ||
|
||
with context.begin_transaction(): | ||
context.run_migrations() | ||
|
||
|
||
def run_migrations_online(): | ||
"""Run migrations in 'online' mode. | ||
In this scenario we need to create an Engine | ||
and associate a connection with the context. | ||
""" | ||
engine = engine_from_config( | ||
config.get_section(config.config_ini_section), | ||
prefix='sqlalchemy.', | ||
poolclass=pool.NullPool) | ||
|
||
connection = engine.connect() | ||
context.configure( | ||
connection=connection, | ||
target_metadata=target_metadata | ||
) | ||
|
||
try: | ||
with context.begin_transaction(): | ||
context.run_migrations() | ||
finally: | ||
connection.close() | ||
|
||
if context.is_offline_mode(): | ||
run_migrations_offline() | ||
else: | ||
run_migrations_online() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
"""${message} | ||
|
||
Revision ID: ${up_revision} | ||
Revises: ${down_revision} | ||
Create Date: ${create_date} | ||
|
||
""" | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = ${repr(up_revision)} | ||
down_revision = ${repr(down_revision)} | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
${imports if imports else ""} | ||
|
||
def upgrade(): | ||
${upgrades if upgrades else "pass"} | ||
|
||
|
||
def downgrade(): | ||
${downgrades if downgrades else "pass"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
build-essential | ||
python | ||
python-software-properties | ||
python-pip | ||
python-setuptools | ||
python-dev | ||
python-virtualenv | ||
python-pip | ||
python-psycopg2 | ||
postgresql | ||
curl | ||
git | ||
git-core | ||
nodejs | ||
openssl | ||
libssl-dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .app import create_app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from .views import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from flask import (Blueprint, render_template, current_app) | ||
|
||
from ..extensions import manager | ||
# from ..models import MyModel | ||
|
||
|
||
def initialize_api(): | ||
# List all Flask-Restless APIs here | ||
# model_api = manager.create_api(MyModel, methods=['GET']) | ||
pass | ||
|
||
|
||
api = Blueprint('api', __name__, url_prefix='/api') |
Oops, something went wrong.