tw2.captcha

A captcha w2 widgets.

Get this source from http://github.com/toscawidgets/tw2.captcha

Captcha
  • size
    • Size of the field
  • placeholder
    • Placeholder text (HTML5 Only)
  • audio
    • Boolean to enable or not audio captcha.
  • audio_icon
    • URL for an audio icon.
  • jpeg_generator
    • Algorithm used to render the captcha image. Options:vanasco_dowty, mcdermott
  • text_generator
    • Text displayed on the captcha image.
  • timeout
    • Time in minutes during which the captcha will be valid.
  • controller_prefix
    • URL prefix of captcha controller
  • picture_width
    • Picture width in pixel.
  • picture_height
    • Picture width in pixel.
  • picture_bg_color
    • Picture background color.
  • picture_fg_color
    • Picture foreground color.
  • text_font_size_min
    • Minimal font size for the text on the captcha.
  • text_font_size_max
    • Maximal font size for the text on the captcha.
  • text_font_path
    • Full path to the font to be used in for the text. Either relative to the package or absolute.
  • text_render_mode
    • Rendering method for the text.
  • ascii_char
    • Character allowed in the ascii text
  • num_char
    • Number of character to put on the captcha
  • start_range
    • For the equation, minimum number allowed
  • stop_range
    • For the equation, maximum number allowed
class DemoCaptcha(Captcha):
    key = "lkdsfhaldskflkfdalkfkahg;ahupiuyghi"
    audio = True
    jpeg_generator = 'vanasco_dowty'
    text_generator = 'random_equation'
<%namespace name="tw" module="tw2.core.mako_util"/>
<span id="${w.attrs['id']}:wrapper">
	<img id="${w.attrs['id']}_img"
		src="${w.controller_prefix}/image/${w.payload}"/>
% if w.audio:
	<a href="${w.controller_prefix}/audio/${w.payload}">
		<img src="${w.audio_icon}" alt="Audio file" />
	</a>
% endif
	<input type="hidden"
		id="${w.attrs['id']}:payload"
		name="${w.attrs['id']}:payload"
		value="${w.payload}"/>
	<input type="text"
		id="${w.attrs['id']}:value"
		name="${w.attrs['id']}:value"/>
</span>