auth.logout() inserts a record in the auth_event table, which includes a
reference to the auth_user table. However, you are deleting the auth_user
record before the auth_event insert, so the user_id being entered in
auth_event no longer exists in auth_user. Try switching the order of
operations -- do auth.logout() before the delete. Otherwise, you can do
auth.logout(log=None) to prevent the even logging.
Anthony
On Saturday, April 13, 2013 4:32:12 AM UTC-4, Annet wrote:
>
> In my application I have a function which allows a user to delete his
> account:
>
>
> @auth.requires(lambda: auth.has_membership(ADMIN) or
> auth.has_membership(VIEW))
> def deleteAccount():
> ....
> db(db.auth_user.nodeID==id).delete()
> auth.logout()
> redirect(URL('cms','index'))
> ....
> return dict(form=form)
>
>
> ... this code results in a error:
>
> <class 'gluon.contrib.pg8000.errors.ProgrammingError'> ('ERROR', '23503',
> 'insert or update on table "auth_event" violates foreign key constraint
> "auth_event_user_id_fkey"')
> Is there a way to bypass the insert in the auth_event table in this case.
>
> Kind regards,
>
> Annet
>
--
---
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/groups/opt_out.