make sure db connection for request is open

This commit is contained in:
Izalia Mae 2024-02-04 05:17:51 -05:00
parent 2fcaea85ae
commit 02ac1fa53b

View file

@ -235,9 +235,6 @@ class Response(AiohttpResponse):
class View(AbstractView):
conn: Connection
def __await__(self) -> Generator[Response]:
if (self.request.method) not in METHODS:
raise HTTPMethodNotAllowed(self.request.method, self.allowed_methods)
@ -250,7 +247,10 @@ class View(AbstractView):
async def _run_handler(self, handler: Awaitable) -> Response:
with self.database.config.connection_class(self.database) as conn:
return await handler(self.request,conn, **self.request.match_info)
# todo: remove on next tinysql release
conn.open()
return await handler(self.request, conn, **self.request.match_info)
@cached_property