Perhaps I'm missing the obvious, but I can't figure out how to make
this work:

db.define_table('users',
        Field('phone','string',unique=True),
        Field('safe','boolean',default=False),
        Field('allow_le','boolean',default=False),
        Field('safe_time','datetime'),
        Field('finished','boolean'),
        Field('finished_time','datetime'),
        Field('start_time','datetime'),
)
db.define_table('contacts',
        Field('user',db.users),
        Field('phone','string'),
        Field('user_recording','string'),
        Field('called','boolean',default=False),
)

db.users.insert(phone='17125551212',safe_time=datetime.datetime.now()
+3600)
db.contacts.insert(user=user_id,user_recording='/var/sounds/
blah.wav',phone='15555551212')

where the db.contacts insert needs the .id from the db.users.insert.
I want both to be within a transaction, but because web2py does
transactions and commits automatically at end, how would I make this
happen?

I understand I could do something insane like commit(), do a query to
get the new ID record, and then do the insert for contacts, and then
if that fails, go delete the record from users, but I'm hoping that
there is a more humane way of doing this?

With Love,
Tara

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.

Reply via email to