-
Notifications
You must be signed in to change notification settings - Fork 57
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
Class based views are not supported #41
Comments
@trivigy thank you for posting this bug report and sorry for the long delay. Yes, as I see Perhaps best solution will be to introduce aiohttp-cors mixin for CBV which will handle
|
Makes sense |
I am using the following workaround to register my classes so that they work with aiohttp_cors: def register_view(app, url, view):
for method in ('get', 'post', 'delete', 'put'):
handler = getattr(view, method, None)
if not handler:
continue
app.router.add_route(method, url, handler) |
@balloob will |
Probably - but I was already using views in a weird way: I wanted to instantiate the views before registering them so I could keep a reference to the state of the house (I'm working on Home Assistant). So I actually had a |
@balloob if you want to instantiate your view classes before registering you don't need |
@rutsky Thanks for the suggestion. Took me a long time to notice that you responded. I actually use a very custom implementation of the View within our system. I personally wanted to add a whole lot more functionalities to the view and therefore re-implemented it. Had to override add_route() functions and all. Therefore this problem was never an issue for my systems but it was certainly a bug worth reporting. |
@balloob's hack works ok for me as well, but I think a ViewMixin would be better. |
Guys, we need a champion for the issue. |
I recently changed job, moved to another country and on paternity leave right now, so I don't have free time right now, sorry. |
Let me setup coverage tools first, I'll return to review after that. |
👍 💯 |
When using web.View as the handler if the route being added for '*' then cors doesn't work because the server seems not to be able to find the OPTIONS. Not sure why that is, I didn't take the time to investigate but my guess is that the * end up taking priority and the routing goes to the * handler instead of the CORS handler.
The text was updated successfully, but these errors were encountered: