def display():
     record = db.person(request.args(0))
form=SQLFORM.factory(db.person, db.affiliation, db.address, db.card, record)
     if form.accepts(request.vars, session):
         record.update_record(**dict(form.vars))
         return dict(form=form)

The problem is that your are giving SQLFORM a row object as you should give it an ID.
record = db.person(request.args(0)) creates a row object so instead o:
form=SQLFORM.factory(db.person, db.affiliation, db.address, db.card, record)
try:
form=SQLFORM.factory(db.person, db.affiliation, db.address, db.card, record[0].id)

or maybe even add an small check that request.args is correct:
     record = db.person(request.args(0))
     if len(record):
form=SQLFORM.factory(db.person, db.affiliation, db.address, db.card, record)
     else:
         response.flash=(T('No record with that ID found'))


Kenneth



Traceback (most recent call last):
   File "/home/rwn/Projects/web2py/gluon/restricted.py", line192, in restricted
     exec ccode in environment
   File"/home/  
<http://127.0.0.1:8000/admin/default/edit/g_bender/controllers/default.py>rwn/Projects/web2py/applications/g_bender/controllers/default.py"
  <http://127.0.0.1:8000/admin/default/edit/g_bender/controllers/default.py>, line132, 
in<module>
   File "/home/rwn/Projects/web2py/gluon/globals.py", line137, in<lambda>
     self._caller = lambda f: f()
   File"/home/  
<http://127.0.0.1:8000/admin/default/edit/g_bender/controllers/default.py>rwn/Projects/web2py/applications/g_bender/controllers/default.py"
  <http://127.0.0.1:8000/admin/default/edit/g_bender/controllers/default.py>, line66, in update
     form=SQLFORM.factory(db.person, db.affiliation, db.address, db.card, 
record=record)
   File "/home/rwn/Projects/web2py/gluon/sqlhtml.py", line1226, in factory
     return SQLFORM(DAL(None).define_table(table_name, *fields), **attributes)
   File "/home/rwn/Projects/web2py/gluon/sqlhtml.py", line772, in __init__
     default = record[fieldname]
   File "/home/rwn/Projects/web2py/gluon/dal.py", line3701, in __getitem__
     return dict.__getitem__(self, key)
KeyError: 'organization'

I think the error is because  I'm only passing a record from db.person.

So how do I actually retrieve the same record set I entered using the technique presented in "one form for multiple tables"? I couldn't find a relevant example to follow in the book.

Thanks.





Reply via email to