Note, if you function already has the proper signature, there is no reason 
to wrap it in a lambda. Also, your callbacks do not have to return an empty 
dictionary (they are not controller actions).

Anthony

On Tuesday, October 20, 2015 at 9:19:20 AM UTC-4, Gael Princivalle wrote:
>
> Thanks Niphlod.
>
> After insert works great:
> def add_phplist_user(f,id):
>     auth_user = db.auth_user(id)
>     #add user
>     db_phplist.phplist_user_user.insert(
>         email = auth_user.email,
>         confirmed = auth_user.newsletter)
>     return dict()
>
> db.auth_user._after_insert.append(lambda f,id: add_phplist_user(f,id))
>
> After update works well also:
>
> def update_phplist_user(s,f):
>     n_rows = db_phplist(db_phplist.phplist_user_user.email == s.email).
> count()
>     if n_rows > 0:
>         #update confirmed
>         db_phplist(db_phplist.phplist_user_user.email == s.email).update(
>                     confirmed = s.newsletter)
>     return dict()
>
> db.auth_user._after_update.append(lambda s,f: update_phplist_user(s,f))
>
> But the after update run also after a new insert, and the f dictionary is 
> empty, so I've got a ticket.
>
> Do you know why?
> Have you got a solution?
>
> Il giorno martedì 20 ottobre 2015 11:53:42 UTC+2, Niphlod ha scritto:
>>
>> see the manual about database callbacks.
>>
>>
>> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#callbacks-on-record-insert--delete-and-update
>>
>> On Tuesday, October 20, 2015 at 11:49:02 AM UTC+2, Gael Princivalle wrote:
>>>
>>> Hello all.
>>>
>>> I would like to run a function everytime there is a modification in auth.
>>>
>>> something like:
>>> auth.settings.onchange = lambda: myfunction()
>>>
>>> Or only if a specific field change:
>>> auth.settings.myfield.onchange = lambda: myfunction()
>>>
>>> Is it possible?
>>>
>>> I need it for changing a field value in another db.
>>>
>>> Thanks, regards.
>>>
>>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to