From e9dfd0573a19e40cd792172fdf2790ad193d29b7 Mon Sep 17 00:00:00 2001 From: Steven Loria Date: Sun, 8 Dec 2013 00:33:32 -0600 Subject: [PATCH] Add Flask-Debug toolbar Also, don't bundle and minify assets in dev enviromnet --- {{cookiecutter.repo_name}}/requirements/dev.txt | 3 +++ .../{{cookiecutter.repo_name}}/app.py | 6 +++--- .../{{cookiecutter.repo_name}}/settings.py | 10 ++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/{{cookiecutter.repo_name}}/requirements/dev.txt b/{{cookiecutter.repo_name}}/requirements/dev.txt index 67594ae..42e94ba 100644 --- a/{{cookiecutter.repo_name}}/requirements/dev.txt +++ b/{{cookiecutter.repo_name}}/requirements/dev.txt @@ -9,3 +9,6 @@ Flask-WebTest>=0.0.6 # Management script Flask-Script + +# Debug toolbar +Flask-DebugToolbar diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/app.py b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/app.py index 751fd9b..cecdd09 100644 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/app.py +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/app.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- from flask import Flask from flask.ext.assets import Environment +from flask_debugtoolbar import DebugToolbarExtension from webassets.loaders import PythonLoader from {{cookiecutter.repo_name}}.settings import ProdConfig from {{cookiecutter.repo_name}}.assets import assets -from {{cookiecutter.repo_name}}.extensions import login_manager -from {{cookiecutter.repo_name}}.database import db +from {{cookiecutter.repo_name}}.extensions import db, login_manager from {{cookiecutter.repo_name}} import public, user @@ -27,11 +27,11 @@ def register_extensions(app): db.init_app(app) login_manager.init_app(app) assets.init_app(app) + toolbar = DebugToolbarExtension(app) return None def register_blueprints(app): - # Register blueprints app.register_blueprint(public.views.blueprint) app.register_blueprint(user.views.blueprint) return None diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/settings.py b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/settings.py index df862f2..c656130 100644 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/settings.py +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/settings.py @@ -1,19 +1,27 @@ # -*- coding: utf-8 -*- import os + class Config(object): SECRET_KEY = 'shhhh' APP_DIR = os.path.abspath(os.path.dirname(__file__)) # This directory PROJECT_ROOT = os.path.abspath(os.path.join(APP_DIR, os.pardir)) BCRYPT_LEVEL = 13 + DEBUG_TB_ENABLED = False # Disable Debug toolbar + DEBUG_TB_INTERCEPT_REDIRECTS = False + class ProdConfig(Config): + '''Production configuration.''' ENV = 'prod' DEBUG = False SQLALCHEMY_DATABASE_URI = 'postgresql://localhost/example' SQLALCHEMY_ECHO = False + DEBUG_TB_ENABLED = False # Disable Debug toolbar + class DevConfig(Config): + '''Development configuration.''' ENV = 'dev' DEBUG = True DB_NAME = "dev.db" @@ -21,3 +29,5 @@ class DevConfig(Config): DB_PATH = os.path.join(Config.PROJECT_ROOT, DB_NAME) SQLALCHEMY_DATABASE_URI = "sqlite:///{0}".format(DB_PATH) SQLALCHEMY_ECHO = True + DEBUG_TB_ENABLED = True + ASSETS_DEBUG = True # Don't bundle/minify static assets