My form processing skills have been pushed beyond my understanding of 
web2py.  Maybe I'm going about this the wrong way and someone with more 
chops can steer me along...

I have two tables.  Table RO is a table of sacrosanct data.  It can be used 
for processing, but must never be changed.  Table W is a working table.  It 
is a complete superset of Table RO -- it all all of RO's fields plus a few 
more.  The idea is that users will pick a record from Table RO, edit it, 
and store the results in Table W.  If the user has already edited the 
record once, then the source for future edits should be Table W and Table 
RO is no longer used.

So in pseudo code, here is my approach:


 if work_table_id:
    form = SQLFORM(db.work_table, work_table_id, ...etc...)

 elif ro_table_id:
    fields = db.ro_table(ro_table_id)
    del fields.id
    form = SQLFORM(db.work_table, ...etc...)
    form.vars.update(**fields)

 form.vars.this = my_preset_for_this
 form.vars.that = my_preset_for_that
 ...

 if form.validate():
    formvars = dict(request.vars) # request.post.vars? form.vars?
    formvars.my_calculated_value1 = calculation1
    formvars.my_calculated_value2 = calculation2
    ...

    id = db.work_table.insert(**formvars)

 elif form.errors:
    response.flash = 'my error message here'


I'm having a hell of a time.  I get different form names depending on which 
path is taken.  I get conflicts between formkey and formname.  I get "value 
is empty" validation failures on fields I'm not using in the form (I 
compute a subset of the fields since the information is redundant in some 
way).  Should I just punt SQLFORM and do it all manually?

-- Joe

-- 

--- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to