Currently I'm doing the following to get the current running app
async def handler(request):
app = request.app
Isn't there another way for getting the current running app? Consider the below snippet (the default for author_id):
class Comment(DeclarativeBase):
author_id = Column(Integer, ForeignKey('member.id'), default=Member.current_logged_in())
class Member(DeclarativeBase):
@classmethod
def current_logged_in()
pass
As the session is kept in the current running app and as you can see it is only accessible from the incoming request, how can I get the current running app to use the session for determining the current_logged_in user and thus be used as the default value for Comment's author_id?
I wish I have made my point.
Right now there is no implicit context for aiohttp application.
BTW don't do synchronous calls (SQLAlchemy ORM in your case) from aiohttp code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With