We can easily determine an object's mro, by accessing its __mro__
attribute.
In my case I have a really complex hierarchy that I'm trying to untangle to avoid the current mro hell we are undergoing.
I have a very long mro chain like this one:
(<class 'CompanyUserViewSet'>, <class 'CompanyGenericViewSet'>,
<class 'CompanyDispatchMixin'>, <class 'CompanyCorsLiteMixin'>,
<class 'CorsLiteMixin'>, <class 'ErrorHandlingMixin'>, ..., <type 'object'>)
This is shortened for the sake of the question, but in this case it sums up to 19
classes.
I currently have a problem: I need to know from which one of these classes python is resolving the as_view
method.
I know I can check these in order, but I fail to see what I'm doing wrong, since the as_view
that is getting called is not the correct one.
The call to the method is pretty simple, we have a CompanyUserViewSet
that Rest Framework is using to build the urls for a router:
view = viewset.as_view(mapping, **route.initkwargs)
How can I determine, given an object and one of its attributes (or methods) from what class is python resolving it?