Add simple manage.py script

master
Steven Loria 11 years ago
parent b7a7994284
commit 48a6bd0c99
  1. 1
      README.rst
  2. 13
      {{cookiecutter.repo_name}}/README.rst
  3. 23
      {{cookiecutter.repo_name}}/manage.py
  4. 3
      {{cookiecutter.repo_name}}/requirements/dev.txt
  5. 4
      {{cookiecutter.repo_name}}/requirements/prod.txt
  6. 2
      {{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/models.py
  7. 2
      {{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/settings.py

@ -13,6 +13,7 @@ Features
- Flask-WTForms with login and registration forms - Flask-WTForms with login and registration forms
- Procfile for deploying to a PaaS (e.g. Heroku) - Procfile for deploying to a PaaS (e.g. Heroku)
- nose for testing - nose for testing
- A simple ``manage.py`` script.
Screenshots Screenshots
----------- -----------

@ -13,4 +13,15 @@ Quickstart
git clone https://github.com/{{cookiecutter.github_username}}/{{ cookiecutter.repo_name }} git clone https://github.com/{{cookiecutter.github_username}}/{{ cookiecutter.repo_name }}
cd {{cookiecutter.repo_name}} cd {{cookiecutter.repo_name}}
pip install -r requirements/dev.txt pip install -r requirements/dev.txt
python run.py python manage.py createdb
python manage.py runserver
Shell
-----
To open the interactive shell, run ::
python manage.py shell
By default, you will have access to ``app``, ``models``, and ``db``.

@ -0,0 +1,23 @@
#!/usr/bin/env python
from flask.ext.script import Manager, Shell, Server
from {{ cookiecutter.repo_name }} import models
from {{ cookiecutter.repo_name }}.main import app, db
manager = Manager(app)
def _make_context():
'''Return context dict for a shell session so you can access
app, db, and models by default.
'''
return {'app': app, 'db': db, 'models': models}
@manager.command
def createdb():
'''Create a database from the tables defined in models.py.'''
db.create_all()
manager.add_command("runserver", Server())
manager.add_command("shell", Shell(make_context=_make_context))
if __name__ == '__main__':
manager.run()

@ -3,3 +3,6 @@
# Testing # Testing
nose nose
# Management script
Flask-Script

@ -1,12 +1,12 @@
# Everything that needed in production # Everything that needed in production
Flask==0.10.1 Flask==0.10.1
Flask-SQLAlchemy==1.0 Flask-SQLAlchemy==1.0
Flask-WTF==0.9.0 Flask-WTF==0.9.2
Jinja2==2.7 Jinja2==2.7
MarkupSafe==0.18 MarkupSafe==0.18
SQLAlchemy==0.8.2 SQLAlchemy==0.8.2
WTForms==1.0.4 WTForms==1.0.4
Werkzeug==0.9.3 Werkzeug==0.9.4
gunicorn==17.5 gunicorn==17.5
itsdangerous==0.23 itsdangerous==0.23
wsgiref==0.1.2 wsgiref==0.1.2

@ -21,6 +21,6 @@ class User(db.Model):
self.password = password self.password = password
def __repr__(self): def __repr__(self):
return '<User %r>' % (self.username) return '<User "{username}">'.format(username=self.username)
db.create_all() db.create_all()

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import os import os
APP_DIR = os.path.abspath(os.path.dirname(__file__)) APP_DIR = os.path.abspath(os.path.dirname(__file__)) # This directory
PROJECT_ROOT = os.path.abspath(os.path.join(APP_DIR, os.pardir)) PROJECT_ROOT = os.path.abspath(os.path.join(APP_DIR, os.pardir))
DB_NAME = "test.db" DB_NAME = "test.db"
DB_PATH = os.path.join(PROJECT_ROOT, DB_NAME) DB_PATH = os.path.join(PROJECT_ROOT, DB_NAME)

Loading…
Cancel
Save