formencode.declarative
– Base class for Validators¶
Declarative objects for FormEncode.
Declarative objects have a simple protocol: you can use classes in lieu of instances and they are equivalent, and any keyword arguments you give to the constructor will override those instance variables. (So if a class is received, we’ll simply instantiate an instance with no arguments).
You can provide a variable __unpackargs__ (a list of strings), and if the constructor is called with non-keyword arguments they will be interpreted as the given keyword arguments.
If __unpackargs__ is (‘*’, name), then all the arguments will be put in a variable by that name.
Also, you can define a __classinit__(cls, new_attrs) method, which will be called when the class is created (including subclasses).
Module Contents¶
-
class
formencode.declarative.
Declarative
(*args, **kw)¶
-
formencode.declarative.
classinstancemethod
(func)¶ Acts like a class method when called from a class, like an instance method when called by an instance. The method should take two arguments, ‘self’ and ‘cls’; one of these will be None depending on how the method was called.