You've already forked snikket-web-portal
Workaround for Flask context change
This commit is contained in:
@@ -16,11 +16,13 @@ import aiohttp
|
|||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
|
|
||||||
from quart import (
|
from quart import (
|
||||||
current_app, _app_ctx_stack, session as http_session, abort, redirect,
|
current_app, session as http_session, abort, redirect,
|
||||||
url_for,
|
url_for,
|
||||||
)
|
)
|
||||||
import quart
|
import quart
|
||||||
|
|
||||||
|
from flask import g as _app_ctx_stack
|
||||||
|
|
||||||
import werkzeug.exceptions
|
import werkzeug.exceptions
|
||||||
|
|
||||||
from . import xmpputil
|
from . import xmpputil
|
||||||
@@ -166,7 +168,7 @@ class HTTPSessionManager:
|
|||||||
})
|
})
|
||||||
|
|
||||||
async def teardown(self, exc: typing.Optional[BaseException]) -> None:
|
async def teardown(self, exc: typing.Optional[BaseException]) -> None:
|
||||||
app_ctx = _app_ctx_stack.top
|
app_ctx = _app_ctx_stack
|
||||||
try:
|
try:
|
||||||
session = getattr(app_ctx, self._app_context_attribute)
|
session = getattr(app_ctx, self._app_context_attribute)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
@@ -183,7 +185,7 @@ class HTTPSessionManager:
|
|||||||
await session.__aexit__(exc_type, exc, traceback)
|
await session.__aexit__(exc_type, exc, traceback)
|
||||||
|
|
||||||
async def __aenter__(self) -> aiohttp.ClientSession:
|
async def __aenter__(self) -> aiohttp.ClientSession:
|
||||||
app_ctx = _app_ctx_stack.top
|
app_ctx = _app_ctx_stack
|
||||||
try:
|
try:
|
||||||
return getattr(app_ctx, self._app_context_attribute)
|
return getattr(app_ctx, self._app_context_attribute)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
|||||||
Reference in New Issue
Block a user