# Path: scan/settings.py
# DB_URL = 'sqlite:///scan.db'
# DEBUG = True
# ROOT_PATH = path(__file__).dirname()
# REPO_PATH = ROOT_PATH.dirname()
# ENV_ROOT = REPO_PATH.dirname()
# DATA_PATH = os.path.join(REPO_PATH, "data")
# TEST_DATA_PATH = os.path.join(DATA_PATH, "test")
# MODEL_PATH = os.path.join(DATA_PATH, "models")
# SECRET_KEY = "30y^$e7henbp@#_w+z9)o9f8tovjrhoq(%vw=%#*(1-1esrh!_"
# USERNAME = "test"
# EMAIL = "test@test.com"
# PASSWORD = "test"
# SQLALCHEMY_DATABASE_URI = DB_URL
# SECURITY_REGISTERABLE = True
# SECURITY_RECOVERABLE = True
# SECURITY_SEND_REGISTER_EMAIL = False
# SECURITY_PASSWORD_HASH = "bcrypt"
# SECURITY_PASSWORD_SALT = SECRET_KEY
# BROKER_TRANSPORT_OPTIONS = {'visibility_timeout': 3600}
# BROKER_URL = 'redis://localhost:6379/3'
# CELERY_RESULT_BACKEND = 'redis://localhost:6379/3'
# CELERY_IMPORTS = ('core.tasks.tasks',)
# CACHE_TYPE = 'redis'
# CACHE_REDIS_URL = 'redis://localhost:6379/4'
# CACHE_REDIS_DB = 4
# MAX_FEATURES = 500
# MODEL_VERSION = 1
# 
# Path: core/database/models.py
# STRING_MAX = 255
# class Role(db.Model, RoleMixin):
# class User(db.Model, UserMixin):
# class Question(db.Model):
# class Essay(db.Model):
# class PredictedScore(db.Model):
# class Model(db.Model):
#     def __repr__(self):
#     def __repr__(self):
# 
# Path: core/web/main_views.py
# class InvalidUser(Exception):
# class InvalidAction(Exception):
# class BaseQuestionView(MethodView):
# class QuestionView(BaseQuestionView):
# class QuestionDetailView(BaseQuestionView):
# class QuestionActionView(BaseQuestionView):
# class EssayUploadView(BaseQuestionView):
# class BaseEssayView(MethodView):
# class EssayDetailView(BaseEssayView):
# class EssayActionView(BaseEssayView):
# class TaskStatusView(MethodView):
# def index():
#     def get_model(self, id):
#     def get_cache_key(self, id):
#     def get_cache(self, id):
#     def set_cache(self, id, val):
#     def get_questions(self):
#     def get(self):
#     def post(self):
#     def get_upload_form(self, model):
#     def get(self, id):
#     def post(self, id):
#     def delete(self, id):
#     def create(self, model):
#     def create_and_score(self, model):
#     def get(self, id, action):
#     def post(self, id):
#     def get_model(self, id):
#     def get_cache_key(self, id):
#     def get_cache(self, id):
#     def set_cache(self, id, val):
#     def delete(self, id):
#     def score(self, model):
#     def get(self, id, action):
#     def get(self, task_id):


from flask import Flask
from flask.ext.security import Security, SQLAlchemyUserDatastore
from flask.ext.babel import Babel
from scan import settings
from celery import Celery
from core.database.models import db, User, Role
from flask.ext.cache import Cache
from core.web.main_views import main_views

def make_celery(app):
    celery = Celery(app.import_name, broker=app.config['BROKER_URL'])
    celery.conf.update(app.config)
    TaskBase = celery.Task
    class ContextTask(TaskBase):
        abstract = True
        def __call__(self, *args, **kwargs):
            with app.app_context():
                return TaskBase.__call__(self, *args, **kwargs)
    celery.Task = ContextTask
    return celery

def create_app():
    app = Flask(__name__, template_folder='templates')
    app.config.from_object('scan.settings')
    db.app = app
    db.init_app(app)
    return app

def create_test_app():
    app = create_app()
    app.config.from_object('scan.test_settings')
    db.app = app
    db.init_app(app)
    return app

app = create_app()

# Path: scan/settings.py
# DB_URL = 'sqlite:///scan.db'
# DEBUG = True
# ROOT_PATH = path(__file__).dirname()
# REPO_PATH = ROOT_PATH.dirname()
# ENV_ROOT = REPO_PATH.dirname()
# DATA_PATH = os.path.join(REPO_PATH, "data")
# TEST_DATA_PATH = os.path.join(DATA_PATH, "test")
# MODEL_PATH = os.path.join(DATA_PATH, "models")
# SECRET_KEY = "30y^$e7henbp@#_w+z9)o9f8tovjrhoq(%vw=%#*(1-1esrh!_"
# USERNAME = "test"
# EMAIL = "test@test.com"
# PASSWORD = "test"
# SQLALCHEMY_DATABASE_URI = DB_URL
# SECURITY_REGISTERABLE = True
# SECURITY_RECOVERABLE = True
# SECURITY_SEND_REGISTER_EMAIL = False
# SECURITY_PASSWORD_HASH = "bcrypt"
# SECURITY_PASSWORD_SALT = SECRET_KEY
# BROKER_TRANSPORT_OPTIONS = {'visibility_timeout': 3600}
# BROKER_URL = 'redis://localhost:6379/3'
# CELERY_RESULT_BACKEND = 'redis://localhost:6379/3'
# CELERY_IMPORTS = ('core.tasks.tasks',)
# CACHE_TYPE = 'redis'
# CACHE_REDIS_URL = 'redis://localhost:6379/4'
# CACHE_REDIS_DB = 4
# MAX_FEATURES = 500
# MODEL_VERSION = 1
# 
# Path: core/database/models.py
# STRING_MAX = 255
# class Role(db.Model, RoleMixin):
# class User(db.Model, UserMixin):
# class Question(db.Model):
# class Essay(db.Model):
# class PredictedScore(db.Model):
# class Model(db.Model):
#     def __repr__(self):
#     def __repr__(self):
# 
# Path: core/web/main_views.py
# class InvalidUser(Exception):
# class InvalidAction(Exception):
# class BaseQuestionView(MethodView):
# class QuestionView(BaseQuestionView):
# class QuestionDetailView(BaseQuestionView):
# class QuestionActionView(BaseQuestionView):
# class EssayUploadView(BaseQuestionView):
# class BaseEssayView(MethodView):
# class EssayDetailView(BaseEssayView):
# class EssayActionView(BaseEssayView):
# class TaskStatusView(MethodView):
# def index():
#     def get_model(self, id):
#     def get_cache_key(self, id):
#     def get_cache(self, id):
#     def set_cache(self, id, val):
#     def get_questions(self):
#     def get(self):
#     def post(self):
#     def get_upload_form(self, model):
#     def get(self, id):
#     def post(self, id):
#     def delete(self, id):
#     def create(self, model):
#     def create_and_score(self, model):
#     def get(self, id, action):
#     def post(self, id):
#     def get_model(self, id):
#     def get_cache_key(self, id):
#     def get_cache(self, id):
#     def set_cache(self, id, val):
#     def delete(self, id):
#     def score(self, model):
#     def get(self, id, action):
#     def get(self, task_id):


# Path: app.py
from flask import Flask
from flask.ext.security import Security, SQLAlchemyUserDatastore
from flask.ext.babel import Babel
from scan import settings
from celery import Celery
from core.database.models import db, User, Role
from flask.ext.cache import Cache
from core.web.main_views import main_views


def make_celery(app):
    celery = Celery(app.import_name, broker=app.config['BROKER_URL'])
    celery.conf.update(app.config)
    TaskBase = celery.Task
    class ContextTask(TaskBase):
        abstract = True
        def __call__(self, *args, **kwargs):
            with app.app_context():
                return TaskBase.__call__(self, *args, **kwargs)
    celery.Task = ContextTask
    return celery

def create_app():
    app = Flask(__name__, template_folder='templates')
    app.config.from_object('scan.settings')
    db.app = app
    db.init_app(app)
    return app

def create_test_app():
    app = create_app()
    app.config.from_object('scan.test_settings')
    db.app = app
    db.init_app(app)
    return app

app = create_app()

app.register_blueprint(main_views)