aschn / drf-tracking

Utils to track requests to Django Rest Framework API views
http://drf-tracking.readthedocs.org/
ISC License
366 stars 95 forks source link

why this line is needed? #128

Closed singhravi1 closed 5 years ago

singhravi1 commented 5 years ago

Hi everyone,

Can anyone please explain why the following line is needed?

https://github.com/aschn/drf-tracking/blob/57344c65fe39923ab2debbf581d9fd0dbc46b2fa/rest_framework_tracking/base_mixins.py#L50

Thanks

avelis commented 5 years ago

The oldest origin point I could find is llinked below. I presume it allows the middleware to go up the change to continue on before working on actual logging.

https://github.com/aschn/drf-tracking/blame/5425159ec6639101c512c7b8818d5f1573b2e1ef/rest_framework_tracking/mixins.py#L87

singhravi1 commented 5 years ago

But it is in the base class and basically overriding itself?

avelis commented 5 years ago

@singhravi1 Sorry, my first response didn't understand your questions intention. If you look at the installation docs, you see that this class is a mixin. But the other pre-requisite is that it has to work with an APIView class. Which inherits from a Django View class. Which has a finalize_response method. This mixin at a high level ensures that the API library completes its work first in its finalize_response method before moving to create a log in this library. I hope that makes sense.

singhravi1 commented 5 years ago

Oh, okay. Now i get it. I was confused as i did not know about the finalize_rezponse method in APIView and the super was called on Base Exceprion class which is the current class only.