forked from dcolish/Cockerel
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
more re-organization of the webapp and associated classes
- Loading branch information
Showing
33 changed files
with
87 additions
and
75 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -1,6 +1,5 @@ | ||
# # | ||
# from flaskext.sqlalchemy import SQLAlchemy | ||
from flaskext.sqlalchemy import SQLAlchemy | ||
|
||
# from webapp import | ||
db = SQLAlchemy() | ||
|
||
# db = SQLAlchemy(app) | ||
__all__ = ['db'] |
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
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 @@ | ||
from base import new_app | ||
|
||
__all__ = ['new_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,52 @@ | ||
""" | ||
cockerel.webapp | ||
--------------- | ||
Main instance of the webapp. All modules will be loaded from this file. To | ||
add a new module you must import it here and register it. | ||
""" | ||
import logging | ||
import os | ||
|
||
from flask import g | ||
|
||
from flaskext.markdown import Markdown | ||
|
||
from cockerel.models import db | ||
|
||
from cockerel.webapp import ( | ||
admin, | ||
classes, | ||
frontend, | ||
lessons, | ||
prover, | ||
) | ||
from cockerel.webapp.prover import ProverExtension | ||
|
||
|
||
def update_config(app): | ||
"""syncronizes the config with the g global request object""" | ||
g.config = app.config | ||
|
||
|
||
def register_modules(app, mod_list): | ||
for x in mod_list: | ||
app.register_module(x) | ||
|
||
|
||
def new_app(app, serialize=False): | ||
logging.basicConfig(level=logging.DEBUG) | ||
md = Markdown(app, extensions=['tables']) | ||
md.register_extension(ProverExtension) | ||
register_modules(app, [admin, classes, frontend, lessons, prover]) | ||
app.secret_key = os.urandom(24) | ||
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db' | ||
app.config['COQD_HOST'] = 'localhost' | ||
app.config['COQD_PORT'] = 8003 | ||
if serialize: | ||
app.config['serialize'] = serialize | ||
|
||
# XXX:dc: kind of a hack but I want to keep the db and the app seperate | ||
db.init_app(app) | ||
db.app = app | ||
|
||
return 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 |
---|---|---|
@@ -1,52 +1,12 @@ | ||
""" | ||
cockerel.webapp | ||
--------------- | ||
Main instance of the webapp. All modules will be loaded from this file. To | ||
add a new module you must import it here and register it. | ||
""" | ||
import logging | ||
import os | ||
# | ||
from flask import Flask | ||
|
||
from flask import Flask, g | ||
from flaskext.sqlalchemy import SQLAlchemy | ||
from flaskext.markdown import Markdown | ||
from admin import admin | ||
from frontend import frontend | ||
from classes import classes | ||
from lessons import lessons | ||
from prover import prover | ||
|
||
logging.basicConfig(level=logging.DEBUG) | ||
|
||
HOST = "localhost" | ||
app = Flask(__name__) | ||
db = SQLAlchemy(app) | ||
md = Markdown(app, extensions=['tables']) | ||
|
||
from .views.prover.mdx_prover import ProverExtension | ||
md.register_extension(ProverExtension) | ||
|
||
from .views import admin | ||
from .views import classes | ||
from .views import frontend | ||
from .views import lessons | ||
from .views import prover | ||
from .utils import register_modules | ||
|
||
register_modules(app, [admin, classes, frontend, lessons, prover]) | ||
|
||
app.secret_key = os.urandom(24) | ||
|
||
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db' | ||
app.config['COQD_HOST'] = 'localhost' | ||
app.config['COQD_PORT'] = 8003 | ||
|
||
# see if the db exists, if not make it and initialize | ||
if not os.path.exists(app.config.get('SQLALCHEMY_DATABASE_URI')): | ||
db.create_all() | ||
|
||
|
||
def update_config(): | ||
"""syncronizes the config with the g global request object""" | ||
g.config = app.config | ||
|
||
|
||
def new_app(serialize): | ||
if serialize: | ||
app.config['serialize'] = serialize | ||
return app | ||
__all__ = ['admin', 'app', 'frontend', 'classes', 'lessons', 'prover'] |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,4 @@ | ||
from prover import prover | ||
from mdx_prover import ProverExtension | ||
|
||
__all__ = ['prover', 'ProverExtension'] |
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
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
File renamed without changes.
This file was deleted.
Oops, something went wrong.
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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