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
|
Rev | Line | |
---|
[2802] | 1 | from zope.schema import TextLine |
---|
| 2 | from zope.component import adapts |
---|
| 3 | from zope.interface import Interface, implements |
---|
[2804] | 4 | from zope.formlib.form import FormFields |
---|
| 5 | from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile |
---|
| 6 | from plone.app.form.base import EditForm |
---|
[2802] | 7 | |
---|
[2801] | 8 | from quintagroup.formlib.captcha import Captcha |
---|
| 9 | |
---|
| 10 | # Define CaptchaFormlibForm form schema |
---|
| 11 | |
---|
| 12 | class 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 | |
---|
| 20 | class 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] | 31 | class CaptchaFormlibForm(EditForm): |
---|
[2804] | 32 | template = ViewPageTemplateFile("example.pt") |
---|
[2802] | 33 | form_fields = FormFields(ICaptchaFormlibFormSchema) |
---|
Note: See
TracBrowser
for help on using the repository browser.