2 from django.conf import settings
12 def qualify(self, request):
15 def __init__(self, request):
16 self.value, self.manual = self.get_value(request)
18 def override(self, value):
22 def get_value(self, request):
23 overrides = getattr(settings, 'EXPERIMENTS_OVERRIDES', {})
26 return overrides[slug], False
28 if self.qualify(request) is False:
31 if self.switchable or request.user.is_staff:
32 cookie_value = request.COOKIES.get(f'EXPERIMENT_{slug}')
33 if cookie_value is not None:
34 if cookie_value == 'on':
36 elif cookie_value == 'off':
41 (slug + request.META['REMOTE_ADDR']).encode('utf-8')
45 return number < self.size, False