-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Route definitions #2004
Route definitions #2004
Changes from 1 commit
a2fbd23
62f653a
2ce063f
727ea50
daa31ec
0c23ebf
6cab8b8
8b44cde
1d5492c
3eb5137
a5c24a0
910cf1c
36d4fc0
de48fda
234ed0e
2f5bb08
d158513
b8ad2f4
7391a69
341da53
ec0630a
9c1845c
a9cbbb4
e2bc869
58686cb
875ae8e
7c54e36
48203d3
68f7225
aaab3ed
c10f4e0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,7 +38,13 @@ | |
|
||
|
||
class RouteDef(namedtuple('_RouteDef', 'method, path, handler, kwargs')): | ||
# TODO: add __repr__ | ||
def __repr__(self): | ||
info = [] | ||
for name, value in sorted(self.kwargs.items()): | ||
info += ", {}={}".format(name, value) | ||
return ("<RouteDef {method} {path} -> {handler.__name__!r}" | ||
"{info}>".format(method=self.method, path=self.path, | ||
handler=self.handler, info=''.join(info))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think will be better if info will be string There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This style is used by asyncio in many places, I like to keep it in aiohttp too |
||
|
||
def register(self, router): | ||
if self.method in hdrs.METH_ALL: | ||
|
@@ -956,7 +962,8 @@ class RouteTableDef(Sequence): | |
def __init__(self): | ||
self._items = [] | ||
|
||
# TODO: add __repr__ | ||
def __repr__(self): | ||
return "<RouteTableDef count={}>".format(len(self._items)) | ||
|
||
def __getitem__(self, index): | ||
return self._items[index] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not only
Route
?What's the meaning of
Def
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we already use
Route
name for routes added byapp.router.add_route()
call.RouteDef
is a scratch for non-added-yet route definition