| 1 |
"""A package (for Nevow) for defining the schema, validation and rendering of |
| 2 |
HTML forms. |
| 3 |
""" |
| 4 |
|
| 5 |
# Not checked by pyflakes: API file with gratuitous imports |
| 6 |
|
| 7 |
version_info = (1, 0, 0) |
| 8 |
version = '.'.join([str(i) for i in version_info]) |
| 9 |
|
| 10 |
from twisted.web import iweb |
| 11 |
from twisted.web import static |
| 12 |
from . import twistedpatch |
| 13 |
|
| 14 |
Request = twistedpatch.MPRequest |
| 15 |
|
| 16 |
from .nevowc import (XMLFile, XMLString, |
| 17 |
addNevowAttributes, |
| 18 |
TemplatedPage, NevowcElement, |
| 19 |
flattenSync, |
| 20 |
CommonRenderers) |
| 21 |
from .types import * |
| 22 |
from .validation import * |
| 23 |
from .widget import * |
| 24 |
from .widgets.multiselect import * |
| 25 |
from .form import Form, Field, Group, ResourceWithForm, FORMS_KEY |
| 26 |
from . import iformal |
| 27 |
|
| 28 |
def widgetFactory(widgetClass, *a, **k): |
| 29 |
def _(original): |
| 30 |
return widgetClass(original, *a, **k) |
| 31 |
return _ |
| 32 |
|
| 33 |
# Register standard adapters |
| 34 |
from twisted.python.components import registerAdapter |
| 35 |
from . import converters |
| 36 |
from .util import (SequenceKeyLabelAdapter, StringableLabelAdapter, |
| 37 |
render_cssid) |
| 38 |
registerAdapter(TextInput, String, iformal.IWidget) |
| 39 |
registerAdapter(TextInput, Integer, iformal.IWidget) |
| 40 |
registerAdapter(TextInput, Float, iformal.IWidget) |
| 41 |
registerAdapter(Checkbox, Boolean, iformal.IWidget) |
| 42 |
registerAdapter(DatePartsInput, Date, iformal.IWidget) |
| 43 |
registerAdapter(TextInput, Time, iformal.IWidget) |
| 44 |
registerAdapter(FileUpload, File, iformal.IWidget) |
| 45 |
registerAdapter(TextAreaList, Sequence, iformal.IWidget) |
| 46 |
registerAdapter(SequenceKeyLabelAdapter, tuple, iformal.IKey) |
| 47 |
registerAdapter(SequenceKeyLabelAdapter, tuple, iformal.ILabel) |
| 48 |
registerAdapter(StringableLabelAdapter, bytes, iformal.ILabel) |
| 49 |
registerAdapter(StringableLabelAdapter, str, iformal.ILabel) |
| 50 |
registerAdapter(StringableLabelAdapter, int, iformal.ILabel) |
| 51 |
registerAdapter(converters.ForceStringConverter, String, iformal.IStringConvertible) |
| 52 |
registerAdapter(converters.DateToDateTupleConverter, Date, iformal.IDateTupleConvertible) |
| 53 |
registerAdapter(converters.BooleanToStringConverter, Boolean, iformal.IBooleanConvertible) |
| 54 |
registerAdapter(converters.BooleanToStringConverter, Boolean, iformal.IStringConvertible) |
| 55 |
registerAdapter(converters.IntegerToStringConverter, Integer, iformal.IStringConvertible) |
| 56 |
registerAdapter(converters.FloatToStringConverter, Float, iformal.IStringConvertible) |
| 57 |
registerAdapter(converters.DateToStringConverter, Date, iformal.IStringConvertible) |
| 58 |
registerAdapter(converters.TimeToStringConverter, Time, iformal.IStringConvertible) |
| 59 |
registerAdapter(converters.NullConverter, File, iformal.IFileConvertible) |
| 60 |
registerAdapter(converters.NullConverter, Sequence, iformal.ISequenceConvertible) |
| 61 |
registerAdapter(converters.SequenceToStringConverter, Sequence, iformal.IStringConvertible) |
| 62 |
|
| 63 |
try: |
| 64 |
Decimal |
| 65 |
except NameError: |
| 66 |
pass |
| 67 |
else: |
| 68 |
registerAdapter(TextInput, Decimal, iformal.IWidget) |
| 69 |
registerAdapter(converters.DecimalToStringConverter, Decimal, iformal.IStringConvertible) |
| 70 |
del SequenceKeyLabelAdapter |
| 71 |
del registerAdapter |