I have some API change suggestions for the @validate decorator:
- Rename the validators parameter to schema. The code
currently allows a dictionary to be passed. But that feature seem
to not be used except for unit testing. It should be removed. This
simplified implementation and documentation.
- Rename the Form class' validate() method to
to_python(). The method has the same signature and behaviour
as the to_python() method in FormEncode schemas and with
this change duck typing becomes easier.
- Do not assign to cherrypy.request.validated_form, instead
use cherrypy.request.validated_entity. With this change, you
can assign to that attribute unconditionally after validation, not
just after validation of a form. Once again, this simplified
implementation and documentation.
With these proposed changes, the signature of the @validate
decorator can change to:
def validate(schema, state_factory=None)
Where schema is either a TurboGears widget or a FormEncode
Schema. This is much simpler and removes the special-casing for
widgets.