If you benefit from web2py hope you feel encouraged to pay it forward by contributing back to society in whatever form you choose!


  • 0
    rochacbruno  6 years ago

    Nice slice!

    I would change a little to:

     def captcha_field(request=request, apikey, apisecret, fieldname="captcha", label="verify"):
        from gluon.tools import Recaptcha
        w = lambda x,y: Recaptcha(request,
                                  'xxxxxxxxxxxxxxxxxxxxxxx',
                                  'yyyyyyyyyyyyyyyyyyyyyyy')
     
        return Field(fieldname, 'string', label=label, widget=w, default='ok')

     

    And using with

    captcha_field(apikey, apisecret, "mycaptcha", "write the security code")

    Also I think it can be included as

    Field.captcha(.....)
    replies (1)
    • michelecomitini 6 years ago

      Those are nice, also it should be moved to a module by using current.request

Commented on:

Adding a captcha to a form as shown in the book requires too much work!! ;-) Here is a simpler way to do it.

Hosting graciously provided by:
Python Anywhere