Skip to content

question: bpython in flask application context #604

@item4

Description

@item4

I want to use bpython in flask application context.

I wrote this code.

config = read_config() # just gen config
app = create_app(config) # just return Flask(__name__).config.update(config)
with app.app_context():
    import bpython
    bpython.embed(locals_=dict(app=app))

But it did not work correctly.

>>> from flask import current_app
>>> current_app.config
Traceback (most recent call last):
  File "<input>", line 1, in <module>
    current_app.config
  File "/Users/item4/.virtualenvs/*/lib/python3.5/site-packages/werkzeug/local.py", line 343, in __getattr__
    return getattr(self._get_current_object(), name)
  File "/Users/item4/.virtualenvs/*/lib/python3.5/site-packages/werkzeug/local.py", line 302, in _get_current_object
    return self.__local()
  File "/Users/item4/.virtualenvs/*/lib/python3.5/site-packages/flask/globals.py", line 34, in _find_app
    raise RuntimeError('working outside of application context')
RuntimeError: working outside of application context

How can I embed bpython in flask application context?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions