def __init__(self, request=None, *args, **kwargs):
        """Initialize form, including captcha question and expected answer."""
        super(CaptchaAuthenticationForm, self).__init__(*args, **kwargs)

        # get previous expected answer before generating new one
        self.captcha_answer = request.session.get(CAPTCHA_SESSION_KEY)

        # only add the captcha field if this request hit the rate limit
        if getattr(request, "limited", False):
            a, b = random.randint(1, 9), random.randint(1, 9)
            # avoid negative answers
            if b > a:
                a, b = b, a
            opname, op = random.choice(OPERATORS.items())

            # store the expected answer in the session
            request.session[CAPTCHA_SESSION_KEY] = op(a, b)

            self.fields["captcha"] = forms.IntegerField(
                widget=forms.TextInput,
                required=False,
                label=u"What is {0} {1} {2}?".format(a, opname, b),
                )
dataset/ETHPy150Open mozilla/moztrap/moztrap/view/users/forms.py/CaptchaAuthenticationForm.__init__/original