hi web2py gurus,

just out of curiousity, i'd like to create a class (let's say Product) that 
represents a record in my table "product".  right now, i can't figure out 
how to have the class attributes (p = Product(); p.price) saved to the 
database without internally having p.__fields_dict__ containing ONLY table 
fields, and then map the p.price to p.__fields_dict__['price'], and finally 
doing something like p.db['product'].insert(p.__fields_dict__).

i'm just wondering if there's any better way to do this, sorry i'm pretty 
new to Python as well and probably am missing something.

ideally, i'd like something that's more like:

p = Product(id=1) or Product()
p.random_var = 'abc'
p.name = 'a'
p.price = 100.0
p.save() # or db['product'].update_or_insert(p) 

thanks a lot!
tom

-- 



Reply via email to