source: products/quintagroup.formlib.captcha/trunk/quintagroup/formlib/captcha/example.py @ 2807

Last change on this file since 2807 was 2807, checked in by mylan, 14 years ago

#195: Updated example form to clarify doctests

  • Property svn:eol-style set to native
File size: 1006 bytes
RevLine 
[2802]1from zope.schema import TextLine
2from zope.component import adapts
3from zope.interface import Interface, implements
[2804]4from zope.formlib.form import FormFields
5from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
6from plone.app.form.base import EditForm
[2802]7
[2801]8from quintagroup.formlib.captcha import Captcha
9     
10# Define CaptchaFormlibForm form schema
11
12class ICaptchaFormlibFormSchema(Interface):
[2807]13    label = TextLine(title=u'Label',
14                     required=False)
[2801]15    captcha = Captcha(title=u'Type the code')
16     
17# Create adapter for any object to ICaptchaFormlibFormSchema
18# schema interface
19
20class CaptchaFormlibFormAdapter(object):
[2802]21    implements(ICaptchaFormlibFormSchema)
[2803]22
23    def __init__(self, context):
24        self.context = context
25
[2801]26    label = u''
27    captcha = None
28     
29# And at the last define the CaptchaFormlibForm form
30
[2802]31class CaptchaFormlibForm(EditForm):
[2804]32    template = ViewPageTemplateFile("example.pt")
[2802]33    form_fields = FormFields(ICaptchaFormlibFormSchema)
Note: See TracBrowser for help on using the repository browser.