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