Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
c103f5d
Introduce Resource concept
asvetlov Jan 4, 2016
1931a9b
Work on impl
asvetlov Jan 4, 2016
859d1f8
Merge branch 'master' into new_router
asvetlov Jan 9, 2016
db48cec
Make a progress on implementing new route system
asvetlov Jan 10, 2016
971a3c9
Introduce ResourceRoute
asvetlov Jan 10, 2016
82e6bc9
Implement ResourceAdapter
asvetlov Jan 10, 2016
4868b19
Drop PrefixResource
asvetlov Jan 10, 2016
cc27d02
Fix reprs
asvetlov Jan 10, 2016
30f9cb0
Fix more tests
asvetlov Jan 10, 2016
783b77b
Make tests green
asvetlov Jan 10, 2016
40c9afc
Drop ReourceAdapter.route
asvetlov Jan 11, 2016
d9c42d6
Merge branch 'master' into new_router
asvetlov Jan 14, 2016
e9e4d72
Fix test for named resources
asvetlov Jan 14, 2016
907e269
Fix ResourceAdapter bug
asvetlov Jan 14, 2016
816d386
More tests
asvetlov Jan 14, 2016
a3c9bd2
Add Route.resource property
asvetlov Jan 14, 2016
df4b843
Add wildcard support
asvetlov Jan 14, 2016
d9dc9ab
Move method and handler checks into BaseRoute
asvetlov Jan 14, 2016
1602c3c
Refactor expect_handler checks
asvetlov Jan 14, 2016
7b8a230
Drop meaningless code
asvetlov Jan 14, 2016
970a905
Reduce source diff
asvetlov Jan 14, 2016
a86213b
Better coverage
asvetlov Jan 14, 2016
9961f34
Fix deprecation text
asvetlov Jan 14, 2016
8ba8424
Finish tests coverage
asvetlov Jan 14, 2016
ae3b9e5
Add deprecation warning for router.register_route
asvetlov Jan 14, 2016
5dc49ed
Add test for deprecation register_route
asvetlov Jan 14, 2016
5d8c895
Work on docs, add a rationale for the change
asvetlov Jan 14, 2016
2ab3800
Work on docs
asvetlov Jan 15, 2016
98cf6a2
More docs
asvetlov Jan 16, 2016
4cb3016
Add a check on double route adding
asvetlov Jan 16, 2016
7341c81
Drop obsolete TODO
asvetlov Jan 16, 2016
dc0e742
Introduce AbstractResource and AbstractRoute
asvetlov Jan 16, 2016
983bc34
More docs
asvetlov Jan 16, 2016
283af3e
Drop abstract route, introduce abstract expect-handler
asvetlov Jan 18, 2016
45a92b6
Drop NEW_ROUTER.txt
asvetlov Jan 18, 2016
d880f9e
Fix typo
asvetlov Jan 18, 2016
a013c91
Merge branch 'master' into new_router
asvetlov Jan 19, 2016
d1a727c
Merge branch 'master' into new_router
asvetlov Jan 25, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ CHANGES

- Enable access log by default #735

- Deprecate app.router.register_route() (the method was not documented
intentionally BTW).

- Deprecate app.router.named_routes() in favor of app.router.named_resources()

- route.add_static accepts pathlib.Path now #743

- Add command line support: `$ python -m aiohttp.web package.main` #740
Expand Down
4 changes: 2 additions & 2 deletions aiohttp/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def handler(self):

@property # pragma: no branch
@abstractmethod
def route(self):
"""Return route for match info"""
def expect_handler(self):
"""Expect handler for 100-continue processing"""


class AbstractView(metaclass=ABCMeta):
Expand Down
60 changes: 26 additions & 34 deletions aiohttp/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class RequestHandler(ServerHttpProtocol):

_meth = 'none'
_path = 'none'
_request = None

def __init__(self, manager, app, router, *,
secure_proxy_ssl_header=None, **kwargs):
Expand All @@ -59,8 +58,6 @@ def connection_lost(self, exc):
self._manager.connection_lost(self, exc)

super().connection_lost(exc)
if self._request is not None:
pass

@asyncio.coroutine
def handle_request(self, message, payload):
Expand All @@ -72,40 +69,35 @@ def handle_request(self, message, payload):
app, message, payload,
self.transport, self.reader, self.writer,
secure_proxy_ssl_header=self._secure_proxy_ssl_header)
self._request = request
self._meth = request.method
self._path = request.path
try:
try:
match_info = yield from self._router.resolve(request)

assert isinstance(match_info, AbstractMatchInfo), match_info

resp = None
request._match_info = match_info
expect = request.headers.get(hdrs.EXPECT)
if expect and expect.lower() == "100-continue":
resp = (
yield from match_info.route.handle_expect_header(
request))

if resp is None:
handler = match_info.handler
for factory in reversed(self._middlewares):
handler = yield from factory(app, handler)
resp = yield from handler(request)

assert isinstance(resp, StreamResponse), \
("Handler {!r} should return response instance, "
"got {!r} [middlewares {!r}]").format(
match_info.handler, type(resp), self._middlewares)
except HTTPException as exc:
resp = exc

resp_msg = yield from resp.prepare(request)
yield from resp.write_eof()
finally:
self._request = None
match_info = yield from self._router.resolve(request)

assert isinstance(match_info, AbstractMatchInfo), match_info

resp = None
request._match_info = match_info
expect = request.headers.get(hdrs.EXPECT)
if expect and expect.lower() == "100-continue":
resp = (
yield from match_info.expect_handler(request))

if resp is None:
handler = match_info.handler
for factory in reversed(self._middlewares):
handler = yield from factory(app, handler)
resp = yield from handler(request)

assert isinstance(resp, StreamResponse), \
("Handler {!r} should return response instance, "
"got {!r} [middlewares {!r}]").format(
match_info.handler, type(resp), self._middlewares)
except HTTPException as exc:
resp = exc

resp_msg = yield from resp.prepare(request)
yield from resp.write_eof()

# notify server about keep-alive
self.keep_alive(resp_msg.keep_alive())
Expand Down
Loading