2
Interfaces for FormEncode (for documentation purposes only)
6
class Attribute(object):
8
def __init__(self, description, name=None):
9
self.description = description
13
class Interface(object):
17
class IDeclarative(Interface):
21
Instantiates this class with all the keywords being used to
22
update the instance variables.
27
Returns a copy with all attributes using the given keywords,
32
class IValidator(IDeclarative):
34
messages = Attribute("""
35
A dictionary of messages (with formatting strings) for error
36
responses""", name='messages')
37
if_missing = Attribute("""
38
If the source that this validator would handle is missing (e.g.,
39
a field that was not specified), use this value. If
40
Validator.NoDefault, then if the field is missing an exception
41
should be raised.""", name='ifMissing')
42
repeating = Attribute("""
43
A boolean; this object accepts lists if true, subvalidators can be
44
found in the validators attribute.""", name='repeating')
45
compound = Attribute("""
46
A boolean; this object has a dictionary of validators if this is
47
true, subvalidators can be found in the field attribute (a
48
dictionary).""", name='compound')
50
def to_python(value, state=None):
52
Convert `value` from its foreign representation to its Python
53
representation. `state` is for application-specific hooks.
56
def from_python(value, state=None):
58
Convert `value` from its Python representation to the foreign
59
representation. `state` is for application-specific hooks.
62
def message(name, default):
64
Return the message (from the `messages` attribute) that goes
65
with `name`, or return default if `name` not found `default`.
69
class ISchema(IValidator):
71
fields = Attribute('A dictionary of (field name: validator)', name='fields')
2
Interfaces for FormEncode (for documentation purposes only)
6
class Attribute(object):
8
def __init__(self, description, name=None):
9
self.description = description
13
class Interface(object):
17
class IDeclarative(Interface):
21
Instantiates this class with all the keywords being used to
22
update the instance variables.
27
Returns a copy with all attributes using the given keywords,
32
class IValidator(IDeclarative):
34
messages = Attribute("""
35
A dictionary of messages (with formatting strings) for error
36
responses""", name='messages')
37
if_missing = Attribute("""
38
If the source that this validator would handle is missing (e.g.,
39
a field that was not specified), use this value. If
40
Validator.NoDefault, then if the field is missing an exception
41
should be raised.""", name='ifMissing')
42
repeating = Attribute("""
43
A boolean; this object accepts lists if true, subvalidators can be
44
found in the validators attribute.""", name='repeating')
45
compound = Attribute("""
46
A boolean; this object has a dictionary of validators if this is
47
true, subvalidators can be found in the field attribute (a
48
dictionary).""", name='compound')
50
def to_python(value, state=None):
52
Convert `value` from its foreign representation to its Python
53
representation. `state` is for application-specific hooks.
56
def from_python(value, state=None):
58
Convert `value` from its Python representation to the foreign
59
representation. `state` is for application-specific hooks.
62
def message(name, default):
64
Return the message (from the `messages` attribute) that goes
65
with `name`, or return default if `name` not found `default`.
69
class ISchema(IValidator):
71
fields = Attribute('A dictionary of (field name: validator)', name='fields')