Work on demo

This commit is contained in:
Andrew Svetlov 2016-02-01 19:25:14 +02:00
parent 607186a168
commit d95b60dd72
4 changed files with 11 additions and 10 deletions

View File

@ -1,7 +1,7 @@
import sqlalchemy as sa import sqlalchemy as sa
metadata = sa.Metadata() metadata = sa.MetaData()
users = sa.Table( users = sa.Table(

View File

@ -1,7 +1,7 @@
import asyncio import asyncio
import sqlalchemy as sa import sqlalchemy as sa
from aiohttp_security.authorization import AbstractAuthorizationPolicy from aiohttp_security.abc import AbstractAuthorizationPolicy
from . import db from . import db

View File

@ -4,7 +4,7 @@ import functools
from aiohttp import web from aiohttp import web
from aiohttp_security import remember, forbid, authorized_user_id, permits from aiohttp_security import remember, forget, authorized_userid, permits
def require(permission): def require(permission):
@ -46,7 +46,7 @@ class Web:
def protected(self, request): def protected(self, request):
pass pass
@asyncio.cororutine @asyncio.coroutine
def configure(self, app): def configure(self, app):
app.add_route('GET', '/', self.index, name='index') app.add_route('GET', '/', self.index, name='index')
app.add_route('POST', '/login', self.login, name='login') app.add_route('POST', '/login', self.login, name='login')

View File

@ -47,9 +47,10 @@ def finalize(srv, app, handler):
yield from app.finish() yield from app.finish()
loop = asyncio.get_event_loop() def main():
srv, app, handler = loop.run_until_complete(init(loop)) loop = asyncio.get_event_loop()
try: srv, app, handler = loop.run_until_complete(init(loop))
try:
loop.run_forever() loop.run_forever()
except KeyboardInterrupt: except KeyboardInterrupt:
loop.run_until_complete((finalize(srv, app, handler))) loop.run_until_complete((finalize(srv, app, handler)))