This kind of answers my question:

http://comments.gmane.org/gmane.comp.python.web2py/72424

but I'll add just to weigh in on Massimo's question re: requirements
for this feature and a use case. My scenario is relatively easy to
describe:
I have a database of various tables representing different object
types. Each of these object types has a REST web service associated
with it that needs to be called relative to CRUD functions around the
database. So all I want is to be able to hook or get a callback on the
database trigger that allows me to do something like:

import requests

def on_insert_success_callback(row):
    # url and auth omitted for brevity
    r = requests.post(insert_api_url, data=row)
    if r.status_code == 200:
       # yay
    else:
        # the second parameter would be needed to prevent the
potential
        # for endless tight loops between failed insert and delete
callbacks
        delete_row(row, no_cascade_callback)


def on_delete_success_callback(row):
    r = request.post(delete_api_url, data=row)
    if r.status_code == 200:
        # yay
    else:
        print 'orphaned object deleted from database but not
webservice'

Given the complexity that Massimo describes, I'd argue for a very
simple CRUD trigger callback set as most all of my web service usage
patterns map to that directly.

Hope this helps.

David






On Dec 13, 2:44 pm, David Watson <[email protected]> wrote:
> I am using smartgrid to generate some table and form interfaces to my
> database. Is there a way to use something like the process function
> with smartgrid to get callbacks? It's not clear to me how I can hook
> into the downstream click-generated events from the edit form, for
> instance. I just want to be able to hook some code into the event
> stream after the successul creation of the database object described
> by a row in the smart grid. I'm hoping there's a way, but if not,
> having that kind of event chaining would be really useful.
>
> Thanks,
> David

Reply via email to