-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Add possibility to register a regexp in router. #291
Conversation
-1 You already can use construction like:
|
No, I can't. What should I do if I need regexp like this by example:
Looks like current solution is:
Of course for current version users could do that:
But it's little bit ugly. Much better What the problem to provide for users more control, which breaks nothing? |
At least it breaks reverse url building by |
Also, what the difference between |
I have not thought about
Second pattern doesn't work in current version aiohttp (because https://github.com/KeepSafe/aiohttp/blob/master/aiohttp/web.py#L1448). So that the main reason why I've made the request for support custom regexp. |
Aha, I see. |
And looks like route.url is already broken:
|
Sure, it works:
|
Oh, I have look to version in pypi before #264 |
Ok, please have a look on the last solution. It makes the deal with slashes as well and pass all tests except this one:
Because the new dispatcher allows to define routes like this as dynamic. route.url(parts={'id': 1}) -> /post"1 |
"Bad pattern '/handler/(?P<to>+++)': nothing to repeat"), s) | ||
self.assertEqual( | ||
"Bad pattern '\/handler\/(?P<to>+++)': nothing to repeat", | ||
str(ctx.exception)) |
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.
Please revert the test: on Python 3.5 error message contains additional info about position in text which causes the error.
The last patch if perfect except my tiny inline notes. |
Hmm. Does you patch violate the rule "A pattern segment (an individual item between / characters in the pattern) may either be a literal string (e.g. foo) or it may be a replacement marker (e.g. {foo}) or a certain combination of both"? |
Please forget about last message: I want to support patterns like |
Add possibility to register a regexp in router.
Thanks! |
I've added possibility to register any regexp in
aiohttp.web.UrlDispatcher
. For that moment there is no opportunity to create some dynamic routes like/test/(?P<any_include_slashes>*.)
or maybe something like this/test/(.*)/?
. The little request implement the functionality.