I think the problem with the original code is that it adds the callback to
the auth_event table itself, so when there is an insert on that table, it
goes into infinite recursion. Instead, just skip that table when adding the
callbacks:
[db[table]._after_insert.append(partial(after_insert_event, table=table))
for table in db.tables if table != 'auth_event']
Or to exclude all Auth tables:
[db[table]._after_insert.append(partial(after_insert_event, table=table))
for table in db.tables if not table.startswith('auth_')]
Anthony
On Wednesday, April 8, 2015 at 4:15:39 AM UTC-4, 黄祥 wrote:
>
> already tried it but return an error
> e.g.
> define all tables on db_wizard_0.py
>
> *models/db_wizard_event.py*
> from functools import partial
>
> def after_insert_event(f, id, table):
> db.auth_event.insert(time_stamp = request.now, client_ip =
> request.client, user_id = auth.user_id,
> origin = '%s/%s' % (request.controller,
> request.function),
> description = 'ID %s created in table %s' % (id,
> table) )
>
> for table in db.tables:
> db[table]._after_insert.append(partial(after_insert_event,
> table=table) )
>
> *error*
> Error snapshot [image: help]
> <https://127.0.0.1/admin/default/ticket/visitor/127.0.0.1.2015-04-08.15-09-29.89a33f10-2a55-4cd2-93b5-630cf1335c82#>
>
> <type 'exceptions.RuntimeError'>(maximum recursion depth exceeded while
> calling a Python object)
>
> an error occured when i access the app, not even create any single new
> record in database.
> any idea how to face this in web2py?
>
> thanks and best regards,
> stifan
>
--
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.