开发者

reCATPCHA redirect isHuman=false

Hi I added reCAPTCHA to a page so far that it can verify a client. Now I want a more graceful failure when isHuman = Falsewith a redirect to the form page in such case with a message on the form page that reCAPTCHA failed. Can you inform what to do rather than just outputting "captcha failed?" so that it can redirect to the form page with Google App Engine's request handler开发者_StackOverflow社区? Here's my code:

def post(self, view): #edit
    challenge = self.request.get('recaptcha_challenge_field')
    response  = self.request.get('recaptcha_response_field')
    remoteip  = os.environ['REMOTE_ADDR']
    cResponse = captcha.submit(
                 challenge,
                 response,
                 CAPTCHA_PRV_KEY,
                 remoteip)

    if cResponse.is_valid==True:
        isHuman=True
    else:
        isHuman=False 
        self.response.out.write('captcha failed')
        return


If you are just looking for a way to redirect back to your original posting page you can use:

self.redirect('your_url')

You could also include a GET variable in the url so that the page is aware that the CAPTCHA failed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜