equal
deleted
inserted
replaced
1 import asyncio |
1 import asyncio |
2 import qmsk.web.application |
2 import qmsk.web.application |
3 import werkzeug |
3 import werkzeug |
|
4 import werkzeug.exceptions |
4 |
5 |
5 class Handler (qmsk.web.application.Handler) : |
6 class Handler (qmsk.web.application.Handler) : |
6 @asyncio.coroutine |
7 @asyncio.coroutine |
7 def process_async (self, **params) : |
8 def process_async (self, **params) : |
8 """ |
9 """ |
24 |
25 |
25 class Application (qmsk.web.application.Application) : |
26 class Application (qmsk.web.application.Application) : |
26 @asyncio.coroutine |
27 @asyncio.coroutine |
27 def __call__ (self, environ, start_response): |
28 def __call__ (self, environ, start_response): |
28 request = werkzeug.Request(environ) |
29 request = werkzeug.Request(environ) |
29 |
30 |
30 handler, params = self.lookup(request) |
31 handler = None |
31 |
32 |
32 try: |
33 try: |
|
34 handler, params = self.lookup(request) |
|
35 |
33 handler.init() |
36 handler.init() |
34 |
37 |
35 response = yield from handler.respond_async(**params) |
38 response = yield from handler.respond_async(**params) |
|
39 |
|
40 except werkzeug.exceptions.HTTPException as error : |
|
41 response = error |
36 |
42 |
37 finally: |
43 finally: |
38 handler.cleanup() |
44 if handler: |
|
45 handler.cleanup() |
39 |
46 |
40 return response(environ, start_response) |
47 return response(environ, start_response) |