Examples ======== We start with a simple credential validation example. Before we proceed let's setup a `virtualenv`_ environment:: $ virtualenv env $ env/bin/easy_install wheezy.html .. _`virtualenv`: http://pypi.python.org/pypi/virtualenv Signin Widget ------------- Suppose we need to add user credential input to an HTML form. In case of error it would be good to display it next to each input. Domain model looks like this:: class Credential(object): def __init__(self): self.username = '' self.password = '' Here is what we can get in html template:: >>> from wheezy.html import widget >>> credential = Credential() >>> errors = {} >>> credential = widget(credential, errors) >>> credential.username.label('Username:') >>> credential.username.textbox(autocomplete='off') >>> credential.username.error() Look how this changes in case of errors:: >>> errors = {'username': ['Required field cannot be left blank.']} >>> credential = widget(credential, errors) >>> credential.username.label('Username:') >>> credential.username.textbox(autocomplete='off') >>> credential.username.error() Required field cannot be left blank. General error message:: >>> errors = {'__ERROR__': ['The username or password provided is incorrect.']} >>> credential = widget(credential, errors) >>> credential.error() The username or password provided is incorrect.