Skip to content
This repository has been archived by the owner on Jul 2, 2021. It is now read-only.

Commit

Permalink
Make init_for call implicit. Fixes #6 (#7)
Browse files Browse the repository at this point in the history
Please use this commit’s changes as the template for changes to all
apps.
  • Loading branch information
jace authored May 4, 2017
1 parent 372e4cb commit 95306e6
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 36 deletions.
14 changes: 6 additions & 8 deletions hgapp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@
assets['hgapp.js'][version] = 'js/app.js'
assets['hgapp.css'][version] = 'css/app.css'


# Configure the app
def init_for(env):
coaster.app.init_app(app, env)
db.init_app(app)
db.app = app
baseframe.init_app(app, requires=['baseframe-bs3', 'hgapp'])
lastuser.init_app(app)
lastuser.init_usermanager(UserManager(db, models.User))
coaster.app.init_app(app)
db.init_app(app)
db.app = app
baseframe.init_app(app, requires=['baseframe-bs3', 'hgapp'])
lastuser.init_app(app)
lastuser.init_usermanager(UserManager(db, models.User))
2 changes: 2 additions & 0 deletions instance/settings-sample.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
#: Debug mode (put this value in development.py only, never in settings.py)
DEBUG = True
#: Site title
SITE_TITLE = 'HasGeek App'
#: Site id (for network bar)
Expand Down
4 changes: 2 additions & 2 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import hgapp.forms as forms
import hgapp.views as views
from hgapp.models import db
from hgapp import app, init_for
from hgapp import app


if __name__ == '__main__':
db.init_app(app)
manager = init_manager(app, db, init_for, hgapp=hgapp, models=models, forms=forms, views=views)
manager = init_manager(app, db, hgapp=hgapp, models=models, forms=forms, views=views)
manager.run()
2 changes: 0 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
Flask
Flask-SQLAlchemy
Flask-Script==0.5.3
Flask-RQ
https://github.com/hasgeek/coaster/archive/master.zip
https://github.com/hasgeek/baseframe/archive/master.zip
https://github.com/hasgeek/flask-lastuser/archive/master.zip
https://github.com/jace/flask-alembic/archive/master.zip
2 changes: 1 addition & 1 deletion rq.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

rqworker -c rqdev hgapp
rqworker -c rqinit hgapp
16 changes: 0 additions & 16 deletions rqdev.py

This file was deleted.

3 changes: 1 addition & 2 deletions rqinit.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from urlparse import urlparse

from hgapp import init_for, app
from hgapp import app

init_for('production')
REDIS_URL = app.config.get('REDIS_URL', 'redis://localhost:6379/0')

# REDIS_URL is not taken by setup_default_arguments function of rq/scripts/__init__.py
Expand Down
4 changes: 1 addition & 3 deletions runserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
# -*- coding: utf-8 -*-

import sys
from hgapp import app, init_for
init_for('dev')
from hgapp import app

try:
port = int(sys.argv[1])
except (IndexError, ValueError):
port = 8000
app.config['DEBUG'] = True
app.run('0.0.0.0', port=port)
1 change: 1 addition & 0 deletions runtests.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/sh
export FLASK_ENV="TESTING"
coverage run `which nosetests`
coverage report
3 changes: 1 addition & 2 deletions website.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import sys
import os.path
sys.path.insert(0, os.path.dirname(__file__))
from hgapp import app as application, init_for
init_for('production')
from hgapp import app as application

0 comments on commit 95306e6

Please sign in to comment.