That's the way to do it. Although I'd use a session variable instead of 
global. If you are using global, you are bound to have some race conditions.

On Monday, January 14, 2013 8:20:16 AM UTC-7, Kostas M wrote:
>
> According to the book, in the DAL chapter, subtitle: 'before and after 
> callbacks', we can use:
>
> >>> db.person._before_delete.append(lambda s: pprint(s))
> >>> db.person._after_delete.append(lambda s: pprint(s))
> where: 
> s is the Set object used for update or delete.
>
> However,
> def person_before_delete(s): #s a Set object
>     anid=s.select()[0].name
>     
> def person_after_delete(s): #s a Set object     
>     anid=s.select()[0].name
>
> The first function, actually can get this name value, whereas the second 
> cannot. In the second case, the
> len(s.select()) returns 0 rows. Is this the expected behaviour?
> I need the 'name' value of the deleted row, for some further actions, and now 
> I am using both "_before_delete"
> to get the value I want and set some global variable in my db.py, and then 
> "_after_delete" to trigger an update
> function of the actual count of the persons left, using the stored global 
> variable. But this way, doesn't look
> so right to me.
>
>
>

-- 



Reply via email to