Skip to content
This repository was archived by the owner on May 7, 2024. It is now read-only.

Remove unnecessary usage of app_ctx_stack #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions flask_sqlalchemy_session/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"""
# pylint: disable=invalid-name
from werkzeug.local import LocalProxy
from flask import _app_ctx_stack, current_app
from flask import current_app
from sqlalchemy.orm import scoped_session

__all__ = ["current_session", "flask_scoped_session"]
Expand All @@ -17,11 +17,6 @@

def _get_session():
# pylint: disable=missing-docstring, protected-access
context = _app_ctx_stack.top
if context is None:
raise RuntimeError(
"Cannot access current_session when outside of an application "
"context.")
app = current_app._get_current_object()
if not hasattr(app, "scoped_session"):
raise AttributeError(
Expand Down