Comments with formencode, recaptcha and htmlfill

written by data, on Dec 11, 2008 5:36:00 AM.

Thanks to the automagic pylons provides, I was able to write my own custom validator for reCAPTCHA in very few lines. I might publish it later on.

I use formencode to validate the form with a simple *validate*-decorator pylons provides. For recaptcha, as said, I provided my own validator, and htmlfill refills the form fields if anything goes wrong.

But I ran into some problems deploying it to my public server. All I got from recaptcha was *verify-params-incorrect*. This was because my lighttpd is compiled with ipv6, and therefore it reports ipv4 addresses as ::ffff:xxx.xxx.xxx.xxx. This can be easily managed with

if remote_ip.begins_with("::ffff:"):
    remote_ip = remote_ip[7:]

Due to recaptcha seemingly not handling ipv6-addresses, I decided to give ipv6 users a free pass; they can post without filling out the captcha. Sadly there won't be that many as my provider does not support any ipv6-glue, but that's for another day.

Comments

  • Faried Nawaz Jan 2, 2009 3:57:24 PM | Permalink - Reply

    Please consider publishing the recaptcha validator.
    • data Oct 18, 2009 12:11:44 AM | Permalink - Reply

      If there are still people interested in this, I will work it over and publish it. Just leave me a note here

  • Tobias Blaschke Jan 4, 2009 3:11:00 AM | Permalink - Reply

    There also is a widget for Tosca Widgets that offers the functionality of ReCaptcha.

    I didn't try it yet. You can find a HowTo in the Turbogears documentation: docs.turbogears.org/2.0/RoughDocs/ToscaWidgets/Cookbook/ReCaptcha

    Using Pylons it should work quite similar. Remember: To use ToscaWidgets in Pylons you have to unpack its egg after easy-install.

Leave a Reply

Tag Cloud

Latest Posts
Archive
Latest Comments

as101: "Great article . Will definitely apply it to my blog.Thanks."

data: "If there are still people interested in this, I will work it over and publish ..."

Tobias Blaschke: "There also is a widget for Tosca Widgets that offers the functionality of ..."

Faried Nawaz: "Please consider publishing the recaptcha validator."

Jochen Kupperschmidt: "Hey :) That's why I wrote this post on how I did it, using a preprocessor. The ..."