django-waffle
django-waffle copied to clipboard
Cookie is only returned for a testing flag set via GET param if that flag is queried during the request
Given:
-
myflag
is set up withtesting=True
- Page A never calls
waffle.flag_is_active(request, 'myflag')
, and none of the templates it loads have{% flag myflag %}
- Page B makes that function call, and/or loads a template with that tag.
- Browser has either
dwft_myflag
cookie asFalse
, or does not have that cookie.
Then (current behavior):
- Request page A with GET param
?dwft_myflag=1
-
dwft_myflag
cookie is never set toTrue
- Request page B without GET param, and
myflag
is treated asFalse
Desired behavior:
- Request page A with GET param
?dwft_myflag=1
-
dwft_myflag
cookie is set toTrue
- Request page B without GET param, and
myflag
is treated asTrue
this has bitten me as well
:+1: a fix for this would be very useful for me too (I wrongly assumed this would be default behaviour)
Honestly, I don't have a good idea of how to fix this. I have a couple of lousy ideas. The problem is that the prefix (dwft_
) is user-configurable—in fact it doesn't even have to be a prefix.
Therein lies the problem. So, a couple of things that could work:
- break backward compat, make it necessarily a prefix
- do something very gross with regex, like
re.compile('^' + test_cookie_template.replace('%s', '(.*)') + '$')
Of those, I'd rather break backward compat.