Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Waffle can't be used directly on DRF's request objects #221
We are building a Django Web Application using Django Rest Framework and AngularJS. We would like to add feature flipping (feature flags) to our framework. Our framework uses token authentication.
We have a problem when we use feature flags based on percentage of users. Waffle appends the attribute "waffles" to the request object. But the attribute does not exist when processed by the waffle middleware.
The request object we are sending is a rest_framework.request.Request type. In the middleware we get a request of type django.core.handlers.wsgi.WSGIRequest
I want to make sure I'm following this correctly, the issue is something like this:
class MyView(rest_framework.APIView): def get(self, request, id=None): if waffle.flag_is_active(request, 'foo'): # request is a rest_framework.request.Request pass return Response(stuff, etc=other_stuff)
Waffle will create the
The problem is that this gets into weird DRF internals that aren't public APIs and are subject to change. I think the original,
What happens if you do
If that works, I'm not sure what to do. I really don't like the idea of mucking with internals or accepting a bunch of code in waffle to deal with the problems DRF creates with its
referenced this issue
May 3, 2018
The problem I identified in this comment #221 (comment) may not be the most important part of the issue. If #1 (comment) is implemented, I don't believe there will be a need to store the
I still would rather keep DRF-specific code segregated—especially if there are optional requirements. I'd rather not duck-type DRF
Coming over from #295. Myself and @martinburchell are using the
That all sounds sensible!
We could probably work on a PR for this if we get a green light. Is there some blocking issues on this?