insert table twice on same table, the second insert is not work

12 views
Skip to first unread message

黄祥

unread,
Jun 28, 2016, 10:13:28 AM6/28/16
to web2py-users
is it possible to insert table twice on same table in web2py?
e.g.
modules/test_event.py
def after_insert_event(f, id, table):
time_stamp = current.request.now
client_ip = current.request.client
user_id = current.auth.user_id
origin = '%s/%s' % (current.request.controller, current.request.function)
mail_to = 'ad...@stifix.com'
messages = 'ID %s created in table %s by %s on %s at %s from %s' % (id, table, 
  user_id, time_stamp, 
  origin, client_ip)
# insert table event : worked
current.db.auth_event.insert(time_stamp = time_stamp, 
client_ip = client_ip, 
user_id = user_id, 
origin = origin, 
description = 'ID %s created in table %s' % (id, table) )

# mail
current.mail.send(mail_to, 
 messages, 
 messages)

# insert table event : not worked no error traceback occured, but the result is not expected
current.db.auth_event.insert(time_stamp = time_stamp, 
client_ip = client_ip, 
user_id = user_id, 
origin = origin, 
description = 'Email sent to %s ID %s created in table %s' % (mail_to, id, table) )

this code only work for the first insert, the second insert is not work (no error traceback occured, but the result is not expected.)
is there any way to achieve it using web2py way?

thanks and best regards,
stifan
Reply all
Reply to author
Forward
0 new messages