t2.create() already has onaccept= (it should have been called
onsave= ) because it does not get called until after the record has
been created/updated within the form.  You are right oncreate/onupdate
could be replaced with onsave, which does not need to be passed to the
SQLFORM.

Ideally, it should work like this:

class T2(...):
def create(...,onsave=..., onaccept=...)
  form = SQLFORM()
  if form.accepts(...,onaccept=onaccept):
    if onsave: onsave(form)
    self.redirect(next=...)

So to summarize, t2 create/update both need onsave/onaccept, and
SQLFORM needs onaccept.


Robin


On Jan 9, 5:43 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
> I can see the use for onaccept but why oncreate/onupdate. This would
> be equivalent to putting the code after accepts(..) returns. Am I
> missing something?
>
> Massimo
>
> On Jan 9, 3:33 pm, Robin B <robi...@gmail.com> wrote:
>
> > SQLFORM.accepts(...) could use hooks: onaccept, oncreate, onupdate.
>
> > onaccept: called after FORM.accept and immediately before create() or
> > insert()
> > oncreate: called after create()
> > onupdate: callled after update()
>
> > These hooks could be used by t2 and passed to SQLFORM:
> > t2.update(onaccept=...,onupdate=...)
> > t2.create(onaccept=...,oncreate=...)
>
> > The important difference is that onaccept must be called after accept
> > passes, but before the record is updated/inserted, so the user can
> > modify attributes (set stamps, set incremental ids, etc) before saving
> > the record.
>
> > For t2 to properly support onaccept= is must be supported by SQLFORM.
>
> > Thoughts?
>
> > Robin
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to