Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

geo_alchemy: make application context available to db function #2410

Merged
merged 1 commit into from
Jul 23, 2024

Conversation

mreid-tt
Copy link
Contributor

@mreid-tt mreid-tt commented Jan 3, 2024

Similar to #2308, this fix is needed for the app to launch

Similar to pallets-eco#2308, this fix is needed for the app to launch
@samuelhwilliams
Copy link
Contributor

samuelhwilliams commented Jul 21, 2024

I don't seem to get any errors about missing app context when running this example. Can you share your error message(s) and what versions of python libraries you're using please?

This is an inoffensive change, I just can't reproduce the issue and I'd be curious to know exactly where the problem is.

@hasansezertasan
Copy link
Member

My traceback:

Traceback (most recent call last):
  File "C:\Users\hasansezertasan\Desktop\flask-admin\examples\geo_alchemy\app.py", line 99, in <module>
    db.create_all()
  File "C:\Users\hasansezertasan\Desktop\flask-admin\venv\Lib\site-packages\flask_sqlalchemy\extension.py", line 900, in create_all
    self._call_for_binds(bind_key, "create_all")
  File "C:\Users\hasansezertasan\Desktop\flask-admin\venv\Lib\site-packages\flask_sqlalchemy\extension.py", line 871, in _call_for_binds
    engine = self.engines[key]
             ^^^^^^^^^^^^
  File "C:\Users\hasansezertasan\Desktop\flask-admin\venv\Lib\site-packages\flask_sqlalchemy\extension.py", line 687, in engines
    app = current_app._get_current_object()  # type: ignore[attr-defined]
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\hasansezertasan\Desktop\flask-admin\venv\Lib\site-packages\werkzeug\local.py", line 519, in _get_current_object
    raise RuntimeError(unbound_message) from None
RuntimeError: Working outside of application context.

This typically means that you attempted to use functionality that needed
the current application. To solve this, set up an application context
with app.app_context(). See the documentation for more information.

Copy link
Member

@hasansezertasan hasansezertasan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@samuelhwilliams samuelhwilliams merged commit d929d53 into pallets-eco:master Jul 23, 2024
@mreid-tt mreid-tt deleted the patch-1 branch July 23, 2024 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants