formencode invalid return type
Question: if an exception occurs in form encode then what will be the return type??

suppose

    
    
    if(request.POST):
            formvalidate = ValidationRule()
            try:
                new = formvalidate.to_python(request.POST)
                data = Users1( n_date = new['n_date'], heading = new['heading'], 
                               desc = new['desc'], link = new['link'], 
                               module_name = new['module_name'] )
                session.add(data)
                session.commit()
            except formencode.Invalid, e:
                errors = e
    

how we can find the field wise error


Answer: I assume you are using formencode(<http://formencode.org>)

you can use unpack_errors to get per field error e.g.

    
    
    import formencode
    from formencode import validators
    
    class UserForm(formencode.Schema):
        first_name = validators.String(not_empty=True)
        last_name = validators.String(not_empty=True)
    
    form = UserForm()
    try:
        form.to_python({})
    except formencode.Invalid,e:
        print e.unpack_errors()
    

it will print a dict of errors per field.

you can use formencode.htmlfill.render to render all errors, in different
ways, read <http://formencode.org/htmlfill.html#errors>

