Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
Pokechu22 edited this page May 1, 2015 · 2 revisions

Sometimes it feels like web development is just creating pages of forms that change data for other pages. Fortunately, there are a number of tools to help reduce the drudgery.

Form Creation

Form Submission

validator.py contains a number of classes for form validation - VLang, VLength, etc. These are passed into the validate() function (also in validator.py) as it decorates a controller:

@validate(
    url=VUrl('url'),
    count=VLimit('limit'),
    things=VByName('id', multiple=True, limit=100),
)
def GET_url_info(self, url, count, things):

You can see plenty of examples of this in api.py.

Many of these validators use the errors defined in errors.py. The set_error() method stores errors in a global location.

Now, validate.py also provides a validatedForm() decorator. This function checks to see if any errors are found in that global error store, and if so, alters the response appropriately so we get error messages.