db.define_table('owner',
                Field('name'))

db.define_table('dog',
                Field('name'),
                Field('breed'),
                Field('owner', db.owner)


db.define_table('sale',
                Field('dog', db.dog),
                Field('new_owner', db.owner),
                Field('old_owner', db.owner))


Controller I was playing around with;

def sale():
    record = db.dogs(request.args(0),active=True)
    form=crud.update(db.dogs,record,onaccept=crud.archive)
    return dict(form=form)

Good day again guys,

I have a 2 part question;

Question 1 - I want to modify the dog database table and change the owner 
field, when the dog is sold for example to a new owner. I read that you can 
use SQLFORM.grid to retrieve the record that you want to update, but I 
haven't come across many similar examples. The above sale controller does 
not modify the record, but instead inserts a new record, so I am guessing 
that its not accessing the record that I want to modify, and I would need 
some further guidance in terms of how to achieve that desired result. 

Question 2 - After the dog table is updated, I want to save a record of the 
transaction in the sale db. That is, the previous owner, the new owner, and 
the dog that was sold. How do I modify the controller to create a record 
insert, based on the modifications made to the dog table?

Thanks much for any suggestions that you have.

Regards,
Rafer



Question 2 -  

-- 
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/groups/opt_out.

Reply via email to