What is the best way to utilize webpy framework/api to inject custom
business validation / success or failure messages? For instance we
want to maybe query a database as part of our validation and we want
to put a custom error message if the validation fails.

- Using site layout templates
- Using web.form
- Using web.session

In the following code snippet is an example of what we're doing:
{code}
...
class login:
    def GET(self):
        form = loginform()
        return render.login('', cfg.getversion(), None,
cfg.allowedSubTrees, form)
    def POST(self):
        form = loginform()
        if not form.validates():
            return render.login('', cfg.getversion(), None,
cfg.allowedSubTrees, form)
        else:
            print "Grrreat success! username: %s, password: %s,
usertree: %s" % (form.d.username, form['password'].value,
form.d.usertree)
            d = DataService()
            validuser = d.login_bind(form.d.username, form.d.password,
form.d.usertree)
            if not validuser:
                print "LOGIN FAILED -- return to login page with error
message"
                return render.login('', cfg.getversion(), None,
cfg.allowedSubTrees, form)
            print "LOGIN SUCCESSFULL"
{code}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to