On Friday, December 16, 2011 6:31:11 AM UTC-5, thodoris wrote:
>
> Thanks for your answers guys. I have another question related to this
> topic.
>
> Say i want to reference an authorized user instead of a person table:
>
> db.define_table('cat',
> Field('name'),
> Field('owner', db.auth_user,
> default=auth.user_id,readable=False,writable=False),)
>
> So that the "owner" of the cat is the logged in user.
> Also i have a view that displays the cat owner.
>
> Lets say i want to have the option to either keep the "cat" or purge it or
> five it to another owner (in general take an action), after the user has
> been deleted. How can i do it?
> If i use ondelete="CASCADE" the cat will be deleted
> ondelete="SET NULL" the owner of the cat will be NULL
> ondelete="NO ACTION"
>
> but there is no way to define take an action. Any ideas??
>
I doubt there is a way to do that with a database constraint. You'll
probably have to handle it in your application logic.