diff options
Diffstat (limited to 'creactistore/_templates/lib/olpcfr/flask/_app.py~')
-rw-r--r-- | creactistore/_templates/lib/olpcfr/flask/_app.py~ | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/creactistore/_templates/lib/olpcfr/flask/_app.py~ b/creactistore/_templates/lib/olpcfr/flask/_app.py~ deleted file mode 100644 index bb8643c..0000000 --- a/creactistore/_templates/lib/olpcfr/flask/_app.py~ +++ /dev/null @@ -1,61 +0,0 @@ -# python import -import os - -# common gettext import -from gettext import gettext - -# server import -from server import config - -# get APP_NAME or default name -APP_NAME = config.Config().get('activity>name') -APP_NAME = 'my_activity' if APP_NAME is None else APP_NAME - -# get app config values -_debug = config.Config().get('server>debug') -_key = config.Config().get('server>secret_key') -_port = config.Config().get('server>port', type_=int) - -# sugar or debug root path factory -try: - from sugar.activity import activity - BUNDLE = activity.get_bundle_path() - ROOT = activity.get_activity_root() -except Exception, e: - BUNDLE = os.path.abspath(os.path.join( - os.path.dirname(__file__), '..', '..', '..')) - ROOT = BUNDLE - - -try: - # flask import - import flask - # init app - app = flask.Flask(__name__) - app.debug = True if _debug is None else _debug - app.secret_key = 'NO_KEY_OOPS' if _key is None else _key - # override jinja template path - app.jinja_loader.searchpath = [os.path.join(BUNDLE, 'templates')] - # init static folder path - from werkzeug import SharedDataMiddleware - app.wsgi_app = SharedDataMiddleware(app.wsgi_app, - {'/static': os.path.join(BUNDLE, 'static')}) -except Exception, e: - app = None - - - -def run_app(): - """run method to trigger at from python class. - """ - if app: - app.run(port=_port) - else: - pass - - -def render(template, **context): - """Crappy hack for gettext issue in templates! - """ - context['_'] = gettext - return flask.render_template(template, **context) |