-
-
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
web.View and multiple route resolution issue #931
Comments
Okay so I misunderstood the logic on the resolution part It actually works the way it should. My bad. But the functionality question still stands. |
Honestly I don't follow what functionality are you requesting |
I am really requesting a functionality. Already implemented it on my end by inheriting bunch of the classes and changing some stuff. Was asking to figure out whether you guys would be interested in the functionality in which case I would spend the extra time writing it into the application instead of overloading stuff. Functionality from flask. When you add dynamic route the groups that get selected in the path of that route during resolution become the function arguments of the handler that is attached. Example: app.router.add_route(
path='/users/{user_id}',
handler=users,
name='users'
async def users(request, user_id): <<<<------------ argument
pass
) In the current aiohttp it only funnels request object through and does not support "default" values for those arguments. Personally I like that functionality and have implemented it for myself. Was asking if I should spend the time porting it into the application for pull request. |
@trivigy very sorry for late answer. We decided to have the only If you are able to make your preferable way on top of But |
No worries at all. I tinker and change for my own personal preference. I'll keep asking and proposing as I go. I will definitely just live with it. |
I have been messing around with the web.View and trying to get similar super convenient functionality as the one that exists in flask. I am talking about dynamic routes variables resolving to handler arguments in the view. Basically the idea is somewhat like this. I would declare a route as such:
Once that works I would like the handler to be able to access those via the argument signature as follows (module view.py):
Few points to mention about the current version not supporting it and then will follow up with a few questions and proposal. Foremost since this logic will try to declare two resources with the same name this will fail. Assuming I fit fix this by overriding UrlDispatcher and implement my own add_route I could potentially attach a single resource with multiple route however there is another issue. It seems that when the resolver is trying to resolve the routes (web_urldispatcher:Resource.resolve) it only acutally checks for the last acceptable method to return. Otherwise it returns no UrlMappingMatchInfo with the allowed_methods. Here is the code:
Since I really would like this kind of functionality I am happy to implement it but if this is not something in line with where the project is moving I would rather implement a wrapping solution personally since I want to continue being up to date with the version releases. Would love some feedback on this, thanks.
The text was updated successfully, but these errors were encountered: