You can also do.

def action():
    return dict(form=SQLFORM(db.table).process())

Or.

def action():
    form = SQLFORM(...)
    form.validate() # as shortcut to if form.accepts...
    return dict(form=form)

http://zerp.ly/rochacbruno
Em 14/08/2011 19:14, "Massimo Di Pierro" <[email protected]>
escreveu:
> We used to do form.accepts(...), later Bruno added form.validate(...)
> and form.process(...). Now we extended this to work with both FORMs
> and SQLFORMs so instead of:
>
> form = SQLFORM(...)
> if form.accepts(request,session):
> # success
> elif form.errors:
> # failure
> else:
> # nothing happened
>
> now you can do
>
>
> form = SQLFORM(...).process()
> if form.accepted:
> # success
> elif form.errors:
> # failure
> else:
> # nothing happened
>
> process takes the same arguments as accepts but does not need to be
> passed request.vars and session. It also takes additional parameters:
> - onsuccess (lambda form: ...)
> - onfailure (lambda form:...)
> - message_onsuccess
> - message_onfailure
> - next (url to redirect in case of success)
>
> Give it a try. This may replace form.accepts(...) as my favorite API.
> It makes the code more compact.

Reply via email to