[web2py] Re: Newbie question:add new record as a copy of an existing row in SQLFORM

2010-12-06 Thread tomt
Thanks for the example and the reference. - Tom On Dec 6, 5:58 pm, villas wrote: > Hi tomt > > I believe it takes the fields from the specified source table and > lines them up with a target table.  Any fields which don't match and > the id are discarded. > > What Denes means is that it wouldn'

[web2py] Re: Newbie question:add new record as a copy of an existing row in SQLFORM

2010-12-06 Thread villas
Hi tomt I believe it takes the fields from the specified source table and lines them up with a target table. Any fields which don't match and the id are discarded. What Denes means is that it wouldn't work when for example you use form.vars from multiple tables which have some identical field na

[web2py] Re: Newbie question:add new record as a copy of an existing row in SQLFORM

2010-12-06 Thread DenesL
See http://groups.google.com/group/web2py/msg/4a9e84fb5ceb2e4f It only works if there are no common field names. I have added this to the book. On Dec 5, 5:07 pm, tomt wrote: > Hi, > > I'm unfamiliar with _filter_fields. I couldn't find it in the manual > but eventually found it in the source in

[web2py] Re: Newbie question:add new record as a copy of an existing row in SQLFORM

2010-12-05 Thread tomt
Hi, I'm unfamiliar with _filter_fields. I couldn't find it in the manual but eventually found it in the source in gluon/tools.py. Am I correct in assuming it is intended to return everything but the id field from a record? (I've just started to learn python) Is there some documentation available

[web2py] Re: Newbie question:add new record as a copy of an existing row in SQLFORM

2010-12-05 Thread mr.freeze
Interesting, I didn't have to set id to None. Perhaps it's db specific. I was using sqlite. Anyway, _filter_fields is better in either case. Thanks! On Dec 5, 7:00 am, villas wrote: > Hi Nathan > > Just a small point, I tried your code example and it seems you have to > set id==None otherwise it

[web2py] Re: Newbie question:add new record as a copy of an existing row in SQLFORM

2010-12-05 Thread villas
Hi Nathan Just a small point, I tried your code example and it seems you have to set id==None otherwise it tries to add a duplicate row with the same id. Anyway, I thought you also might like this alternative using _filter_fields, just because it's shorter. Maybe it's got other issues, but it se

[web2py] Re: Newbie question:add new record as a copy of an existing row in SQLFORM

2010-12-04 Thread tomt
Thanks to both of the responders. The reference and example have answered my question. (and introduced some concepts I was unfamiliar with) - Tom On Dec 3, 9:30 pm, "mr.freeze" wrote: > Here is an example: > > Model > - > db.define_table('things',Field('name',requires=IS_NOT_EMPTY()), >  

[web2py] Re: Newbie question:add new record as a copy of an existing row in SQLFORM

2010-12-03 Thread mr.freeze
Here is an example: Model - db.define_table('things',Field('name',requires=IS_NOT_EMPTY()), Field('age','integer'),Field('weight','double')) db.things.id.represent = lambda v: A(v,_href=URL(vars=dict(dupe=v)), _onclick='return confirm("Copy

[web2py] Re: Newbie question:add new record as a copy of an existing row in SQLFORM

2010-12-03 Thread DenesL
Hi Tom, you can use dbio=False in the accepts and do the insert "manually" as explained in http://web2py.com/book/default/chapter/07#SQLFORM-without-database-IO On Dec 3, 7:12 pm, tomt wrote: > Hi, > > I've started to write a simple application to learn web2py. I am using > SQLFORM to insert,