Skip to content

Commit

Permalink
Add class based view and CBV mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
ri-gilfanov committed Apr 19, 2021
1 parent 6d4eb98 commit 70bcefc
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion aiohttp_sqlalchemy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from aiohttp.web import middleware
from aiohttp.web import middleware, View
from aiohttp.abc import AbstractView
from asyncio import iscoroutinefunction
from functools import wraps
Expand Down Expand Up @@ -52,3 +52,15 @@ def sa_engine(engine: 'AsyncEngine', key: str = 'sa_main') -> 'Tuple[AsyncEngine
def setup(app: 'Application', engines: 'Iterable[Tuple[AsyncEngine, str]]'):
for engine, app_key in engines:
app[app_key] = engine


class SAViewMixin:
request: 'Request'

@property
def sa_main(self):
return self.request['sa_main']


class SAView(View, SAViewMixin):
pass

0 comments on commit 70bcefc

Please sign in to comment.