I suggested it 2 years ago. I'll be happy if it come true someday, in web2py.
I see it as database triggers: before_<event> & after_<event>. I.e: before_insert, after_insert. Event can be: insert, update, delete, query. "before_insert" receives values that will be inserted on database. It is the last chance to modify, check some value or make run some routine before register is inserted. "after_insert" receives values just stored there. "before_update" receives data stored on the database, before the record is updated. As "before_insert", this is a last chance event. "after_update" receives data contents after the update took place. "before_delete" receives data stored on the database. As "before_update" does. Also, it's a last chance event. "after_delete" receives same data, but after register was deleted. "before" and "after" query I don't see as important. Web2py already has virtual and computed fields. But would be nice to log accesses to some table. I worked with these triggers on Sybase, many years ago. But I remember how it was nice to make stored procedures and triggers counting on these events (except query events. I just saw it on Oracle), guaranteeing db integrity. -- Vinicius Assef. On Tue, Oct 11, 2011 at 7:42 PM, Massimo Di Pierro <massimo.dipie...@gmail.com> wrote: > the problem with this is not the names. ;-) > > Consider the case of preupdate and onupdate. > > db(db.person.age>18).update(can_drink=True) > > What information should be passed to preupdate and update? tablename? > query? {'can_drink':True}? Number of affected records? Should there be > one onselect per table? We do not want to call onupdate for every > table, do we (performance issues)? > > What about? > > db(db.person.id=2).update(can_drink=True) > > What about > > > db(db.person).select(left=db.dog.on(db.dog.owner==db.person.id),limitby=(0,1)) > > What should we pass to onselect? query? left? limitby? all arguments? > number of returned records? returned records? In this case we cannot > pass one table because because more than one table may be involved. > > Every one of those callbacks would need a different signature. It > would not be obvious and I am not sure people would agree. > I do not oppose to this. I just want to hear more from you. > > Massimo > > > > On Oct 11, 4:57 pm, Bruno Rocha <rochacbr...@gmail.com> wrote: >> Would be nice to have some global events in web2py workflow. I can imagine >> some useful hooks: >> >> workflow global events: >> >> onrequest # before the execution of action/model >> >> prerender # after the execution of action/model but before the view >> rendering >> >> onrender # after the view render but before the output >> >> onresponse # after all the request process finished. >> >> DAL global events: >> >> preselect - onselect >> preinsert - oninsert >> preupdate - onupdate >> predelete - ondelete >> >> ASPnet has some usefull event system (oninit, onload, pageload etc..) >> >> I dont even know if it is possible to trigger all of them in web2py and how >> can it cost. but would be nice to have it. >> >> http://zerp.ly/rochacbruno >> Em 11/10/2011 17:23, "Massimo Di Pierro" <massimo.dipie...@gmail.com> >> escreveu: >> >> >> >> >> >> >> >> > Not yet at the db level but at the form level: >> >> > form=SQLFORM(...).process(onsuccess=lambda form:...) >> >> > On Oct 11, 3:11 am, Manuele <manuele.pese...@gmail.com> wrote: >> > > Hi, >> > > is there a way to trigger some functions on database eventes, for >> > > example on new record? >> >> > > thanks a lot >> >> > > Manuele