formencode.htmlfill_schemabuilder – Read a Schema from an HTML Form

Extension to htmlfill that can parse out schema-defining statements.

You can either pass SchemaBuilder to htmlfill.render (the listen argument), or call parse_schema to just parse out a Schema object.

Module Contents

formencode.htmlfill_schemabuilder.parse_schema(form)

Given an HTML form, parse out the schema defined in it and return that schema.

class formencode.htmlfill_schemabuilder.SchemaBuilder(validators={'_': <function <lambda>>, '__all__': ['Invalid', 'FancyValidator', 'Validator', 'ConfirmType', 'Wrapper', 'Constant', 'MaxLength', 'MinLength', 'NotEmpty', 'Empty', 'Regex', 'PlainText', 'OneOf', 'DictConverter', 'IndexListConverter', 'DateValidator', 'Bool', 'RangeValidator', 'Int', 'Number', 'ByteString', 'UnicodeString', 'String', 'Set', 'Email', 'URL', 'XRI', 'OpenId', 'FieldStorageUploadConverter', 'FileUploadKeeper', 'DateConverter', 'TimeConverter', 'ISODateTimeConverter', 'StripField', 'StringBool', 'StringBoolean', 'SignedString', 'IPAddress', 'CIDR', 'MACAddress', 'FormValidator', 'RequireIfMissing', 'RequireIfPresent', 'RequireIfMatching', 'FieldsMatch', 'CreditCardValidator', 'CreditCardExpires', 'CreditCardSecurityCode'], '__builtins__': {'ArithmeticError': <class 'ArithmeticError'>, 'AssertionError': <class 'AssertionError'>, 'AttributeError': <class 'AttributeError'>, 'BaseException': <class 'BaseException'>, 'BlockingIOError': <class 'BlockingIOError'>, 'BrokenPipeError': <class 'BrokenPipeError'>, 'BufferError': <class 'BufferError'>, 'BytesWarning': <class 'BytesWarning'>, 'ChildProcessError': <class 'ChildProcessError'>, 'ConnectionAbortedError': <class 'ConnectionAbortedError'>, 'ConnectionError': <class 'ConnectionError'>, 'ConnectionRefusedError': <class 'ConnectionRefusedError'>, 'ConnectionResetError': <class 'ConnectionResetError'>, 'DeprecationWarning': <class 'DeprecationWarning'>, 'EOFError': <class 'EOFError'>, 'Ellipsis': Ellipsis, 'EnvironmentError': <class 'OSError'>, 'Exception': <class 'Exception'>, 'False': False, 'FileExistsError': <class 'FileExistsError'>, 'FileNotFoundError': <class 'FileNotFoundError'>, 'FloatingPointError': <class 'FloatingPointError'>, 'FutureWarning': <class 'FutureWarning'>, 'GeneratorExit': <class 'GeneratorExit'>, 'IOError': <class 'OSError'>, 'ImportError': <class 'ImportError'>, 'ImportWarning': <class 'ImportWarning'>, 'IndentationError': <class 'IndentationError'>, 'IndexError': <class 'IndexError'>, 'InterruptedError': <class 'InterruptedError'>, 'IsADirectoryError': <class 'IsADirectoryError'>, 'KeyError': <class 'KeyError'>, 'KeyboardInterrupt': <class 'KeyboardInterrupt'>, 'LookupError': <class 'LookupError'>, 'MemoryError': <class 'MemoryError'>, 'ModuleNotFoundError': <class 'ModuleNotFoundError'>, 'NameError': <class 'NameError'>, 'None': None, 'NotADirectoryError': <class 'NotADirectoryError'>, 'NotImplemented': NotImplemented, 'NotImplementedError': <class 'NotImplementedError'>, 'OSError': <class 'OSError'>, 'OverflowError': <class 'OverflowError'>, 'PendingDeprecationWarning': <class 'PendingDeprecationWarning'>, 'PermissionError': <class 'PermissionError'>, 'ProcessLookupError': <class 'ProcessLookupError'>, 'RecursionError': <class 'RecursionError'>, 'ReferenceError': <class 'ReferenceError'>, 'ResourceWarning': <class 'ResourceWarning'>, 'RuntimeError': <class 'RuntimeError'>, 'RuntimeWarning': <class 'RuntimeWarning'>, 'StopAsyncIteration': <class 'StopAsyncIteration'>, 'StopIteration': <class 'StopIteration'>, 'SyntaxError': <class 'SyntaxError'>, 'SyntaxWarning': <class 'SyntaxWarning'>, 'SystemError': <class 'SystemError'>, 'SystemExit': <class 'SystemExit'>, 'TabError': <class 'TabError'>, 'TimeoutError': <class 'TimeoutError'>, 'True': True, 'TypeError': <class 'TypeError'>, 'UnboundLocalError': <class 'UnboundLocalError'>, 'UnicodeDecodeError': <class 'UnicodeDecodeError'>, 'UnicodeEncodeError': <class 'UnicodeEncodeError'>, 'UnicodeError': <class 'UnicodeError'>, 'UnicodeTranslateError': <class 'UnicodeTranslateError'>, 'UnicodeWarning': <class 'UnicodeWarning'>, 'UserWarning': <class 'UserWarning'>, 'ValueError': <class 'ValueError'>, 'Warning': <class 'Warning'>, 'ZeroDivisionError': <class 'ZeroDivisionError'>, '__build_class__': <built-in function __build_class__>, '__debug__': True, '__doc__': "Built-in functions, exceptions, and other objects.nnNoteworthy: None is the `nil' object; Ellipsis represents `...' in slices.", '__import__': <built-in function __import__>, '__loader__': <class '_frozen_importlib.BuiltinImporter'>, '__name__': 'builtins', '__package__': '', '__spec__': ModuleSpec(name='builtins', loader=<class '_frozen_importlib.BuiltinImporter'>), 'abs': <built-in function abs>, 'all': <built-in function all>, 'any': <built-in function any>, 'ascii': <built-in function ascii>, 'bin': <built-in function bin>, 'bool': <class 'bool'>, 'breakpoint': <built-in function breakpoint>, 'bytearray': <class 'bytearray'>, 'bytes': <class 'bytes'>, 'callable': <built-in function callable>, 'chr': <built-in function chr>, 'classmethod': <class 'classmethod'>, 'compile': <built-in function compile>, 'complex': <class 'complex'>, 'copyright': Copyright (c) 2001-2020 Python Software Foundation. All Rights Reserved. Copyright (c) 2000 BeOpen.com. All Rights Reserved. Copyright (c) 1995-2001 Corporation for National Research Initiatives. All Rights Reserved. Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam. All Rights Reserved., 'credits': Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands for supporting Python development. See www.python.org for more information., 'delattr': <built-in function delattr>, 'dict': <class 'dict'>, 'dir': <built-in function dir>, 'divmod': <built-in function divmod>, 'enumerate': <class 'enumerate'>, 'eval': <built-in function eval>, 'exec': <built-in function exec>, 'exit': Use exit() or Ctrl-D (i.e. EOF) to exit, 'filter': <class 'filter'>, 'float': <class 'float'>, 'format': <built-in function format>, 'frozenset': <class 'frozenset'>, 'getattr': <built-in function getattr>, 'globals': <built-in function globals>, 'hasattr': <built-in function hasattr>, 'hash': <built-in function hash>, 'help': Type help() for interactive help, or help(object) for help about object., 'hex': <built-in function hex>, 'id': <built-in function id>, 'input': <built-in function input>, 'int': <class 'int'>, 'isinstance': <built-in function isinstance>, 'issubclass': <built-in function issubclass>, 'iter': <built-in function iter>, 'len': <built-in function len>, 'license': Type license() to see the full license text, 'list': <class 'list'>, 'locals': <built-in function locals>, 'map': <class 'map'>, 'max': <built-in function max>, 'memoryview': <class 'memoryview'>, 'min': <built-in function min>, 'next': <built-in function next>, 'object': <class 'object'>, 'oct': <built-in function oct>, 'open': <built-in function open>, 'ord': <built-in function ord>, 'pow': <built-in function pow>, 'print': <built-in function print>, 'property': <class 'property'>, 'quit': Use quit() or Ctrl-D (i.e. EOF) to exit, 'range': <class 'range'>, 'repr': <built-in function repr>, 'reversed': <class 'reversed'>, 'round': <built-in function round>, 'set': <class 'set'>, 'setattr': <built-in function setattr>, 'slice': <class 'slice'>, 'sorted': <built-in function sorted>, 'staticmethod': <class 'staticmethod'>, 'str': <class 'str'>, 'sum': <built-in function sum>, 'super': <class 'super'>, 'tuple': <class 'tuple'>, 'type': <class 'type'>, 'vars': <built-in function vars>, 'zip': <class 'zip'>}, '__cached__': '/home/docs/checkouts/readthedocs.org/user_builds/formencode/checkouts/stable/formencode/__pycache__/validators.cpython-37.pyc', '__doc__': 'nValidator/Converters for use with FormEncode.n', '__file__': '/home/docs/checkouts/readthedocs.org/user_builds/formencode/checkouts/stable/formencode/validators.py', '__loader__': <_frozen_importlib_external.SourceFileLoader object>, '__name__': 'formencode.validators', '__package__': 'formencode', '__spec__': ModuleSpec(name='formencode.validators', loader=<_frozen_importlib_external.SourceFileLoader object>, origin='/home/docs/checkouts/readthedocs.org/user_builds/formencode/checkouts/stable/formencode/validators.py'), 'absolute_import': _Feature((2, 5, 0, 'alpha', 1), (3, 0, 0, 'alpha', 0), 16384), 'bool': <class 'formencode.validators.Bool'>, 'bytestring': <class 'formencode.validators.ByteString'>, 'cgi': <module 'cgi' from '/home/docs/.pyenv/versions/3.7.9/lib/python3.7/cgi.py'>, 'cidr': <class 'formencode.validators.CIDR'>, 'confirmtype': <class 'formencode.validators.ConfirmType'>, 'constant': <class 'formencode.validators.Constant'>, 'creditcardexpires': <class 'formencode.validators.CreditCardExpires'>, 'creditcardsecuritycode': <class 'formencode.validators.CreditCardSecurityCode'>, 'creditcardvalidator': <class 'formencode.validators.CreditCardValidator'>, 'dateconverter': <class 'formencode.validators.DateConverter'>, 'datetime_isotime': <function datetime_isotime>, 'datetime_makedate': <function datetime_makedate>, 'datetime_module': None, 'datetime_now': <function datetime_now>, 'datetime_time': <function datetime_time>, 'datevalidator': <class 'formencode.validators.DateValidator'>, 'deprecation_warning': <function deprecation_warning>, 'dictconverter': <class 'formencode.validators.DictConverter'>, 'email': <class 'formencode.validators.Email'>, 'empty': <class 'formencode.validators.Empty'>, 'fancyvalidator': <class 'formencode.api.FancyValidator'>, 'fieldsmatch': <class 'formencode.validators.FieldsMatch'>, 'fieldstorageuploadconverter': <class 'formencode.validators.FieldStorageUploadConverter'>, 'fileuploadkeeper': <class 'formencode.validators.FileUploadKeeper'>, 'formvalidator': <class 'formencode.validators.FormValidator'>, 'have_dns': False, 'http_client': None, 'identity': validators.Identity, 'idna': <module 'encodings.idna' from '/home/docs/checkouts/readthedocs.org/user_builds/formencode/envs/stable/lib/python3.7/encodings/idna.py'>, 'import_datetime': <function import_datetime>, 'indexlistconverter': <class 'formencode.validators.IndexListConverter'>, 'int': <class 'formencode.validators.Int'>, 'invalid': <class 'formencode.api.Invalid'>, 'ipaddress': <class 'formencode.validators.IPAddress'>, 'iphonenumbervalidator': <function IPhoneNumberValidator>, 'is_empty': <function is_empty>, 'isodatetimeconverter': <class 'formencode.validators.ISODateTimeConverter'>, 'locale': <module 'locale' from '/home/docs/checkouts/readthedocs.org/user_builds/formencode/envs/stable/lib/python3.7/locale.py'>, 'macaddress': <class 'formencode.validators.MACAddress'>, 'map': <class 'map'>, 'maxlength': <class 'formencode.validators.MaxLength'>, 'minlength': <class 'formencode.validators.MinLength'>, 'mxdatetime_module': None, 'nodefault': <class 'formencode.api.NoDefault'>, 'notempty': <class 'formencode.validators.NotEmpty'>, 'number': <class 'formencode.validators.Number'>, 'oneof': <class 'formencode.validators.OneOf'>, 'openid': <class 'formencode.validators.OpenId'>, 'phonenumber': <function PhoneNumber>, 'plaintext': <class 'formencode.validators.PlainText'>, 'postalcode': <function PostalCode>, 'random': None, 'range': <class 'range'>, 'rangevalidator': <class 'formencode.validators.RangeValidator'>, 're': <module 're' from '/home/docs/checkouts/readthedocs.org/user_builds/formencode/envs/stable/lib/python3.7/re.py'>, 'regex': <class 'formencode.validators.Regex'>, 'requireifmatching': <class 'formencode.validators.RequireIfMatching'>, 'requireifmissing': <class 'formencode.validators.RequireIfMissing'>, 'requireifpresent': <class 'formencode.validators.RequireIfMissing'>, 'set': <class 'formencode.validators.Set'>, 'sha1': None, 'signedstring': <class 'formencode.validators.SignedString'>, 'six': <module 'six' from '/home/docs/checkouts/readthedocs.org/user_builds/formencode/envs/stable/lib/python3.7/site-packages/six.py'>, 'socket': None, 'stateprovince': <function StateProvince>, 'string': <class 'formencode.validators.UnicodeString'>, 'stringbool': <class 'formencode.validators.StringBool'>, 'stringboolean': <class 'formencode.validators.StringBool'>, 'stripfield': <class 'formencode.validators.StripField'>, 'timeconverter': <class 'formencode.validators.TimeConverter'>, 'unicodestring': <class 'formencode.validators.UnicodeString'>, 'url': <class 'formencode.validators.URL'>, 'urlparse': None, 'validator': <class 'formencode.api.Validator'>, 'validators': <function validators>, 'warnings': <module 'warnings' from '/home/docs/checkouts/readthedocs.org/user_builds/formencode/envs/stable/lib/python3.7/warnings.py'>, 'wrapper': <class 'formencode.validators.Wrapper'>, 'xri': <class 'formencode.validators.XRI'>})