librelist archives

« back to archive

working outside of request context

working outside of request context

From:
XiaoPing Tang
Date:
2012-05-20 @ 02:01
def create_app():

    application = Flask(__name__)

    @application.context_processor
    def context_processor():
        return dict(
                config=application.config
            )

service.py
---------------
from flask import current_app

current_app.config['PATH']

File
"/Users/Tang/.virtualenv/lib/python2.7/site-packages/flask/globals.py",
line 19, in _lookup_object
    raise RuntimeError('working outside of request context')

Re: [flask] working outside of request context

From:
Adam Patterson
Date:
2012-05-21 @ 16:12
http://flask.pocoo.org/docs/reqcontext/

On Sat, May 19, 2012 at 9:01 PM, XiaoPing Tang <xiaoping.tang@gmail.com> wrote:
> def create_app():
>
>     application = Flask(__name__)
>
>     @application.context_processor
>     def context_processor():
>         return dict(
>                 config=application.config
>             )
>
> service.py
> ---------------
> from flask import current_app
>
> current_app.config['PATH']
>
> File "/Users/Tang/.virtualenv/lib/python2.7/site-packages/flask/globals.py",
> line 19, in _lookup_object
>     raise RuntimeError('working outside of request context')