Hi,
Suppose I have two tables, with a one-to-one relationship:

db.define_table('user', Field('name'));
db.define_table('car', Field('color'), Field('user_id', db.user))

What is the easiest way to create an SQLFORM that would store *correlated*data 
in both fields? For instance, create a user with name Steve who owns a 
red car, that would create two registries (name=Steve), (color=red, 
user_id=<Steve's id>). As far as I'm concerned, I could do something like 
this:

form=SQLFORM.factory(db.user, db.car)
if form.process().accepted:
    # for what I've tested, only the user was inserted, so I have to insert 
the car manually
    if db.car.insert(color=request.vars.color, user_id=form.vars.id):
        response.flash(T('Eh nois que voa'))

But I'm not sure this is the best approach (in terms of security, 
performance and software engineering). Any insights?
Thanks

Reply via email to