I'm punch drunk from looking at this one! Traceback
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. Traceback (most recent call last): File "/home/peter/web2py/gluon/restricted.py", line 227, in restricted exec ccode in environment File "/home/peter/web2py/applications/PAPAIM/controllers/default.py" <http://127.0.0.1:8000/admin/default/edit/PAPAIM/controllers/default.py>, line 717, in <module> File "/home/peter/web2py/gluon/globals.py", line 417, in <lambda> self._caller = lambda f: f() File "/home/peter/web2py/gluon/tools.py", line 4241, in f return action(*a, **b) File "/home/peter/web2py/applications/PAPAIM/controllers/default.py" <http://127.0.0.1:8000/admin/default/edit/PAPAIM/controllers/default.py>, line 492, in view_payment form=SQLFORM(db.payment,payment) File "/home/peter/web2py/gluon/sqlhtml.py", line 1260, in __init__ inp = represent(field, default, record) File "/home/peter/web2py/gluon/sqlhtml.py", line 68, in represent return f(value) File "/usr/local/lib/python2.7/dist-packages/pydal/helpers/methods.py", line 265, in __call__ return value if value is None else _fieldformat(self.ref, value) File "/usr/local/lib/python2.7/dist-packages/pydal/helpers/methods.py", line 253, in _fieldformat return r._format % row File "/usr/local/lib/python2.7/dist-packages/pydal/objects.py", line 76, in __getitem__ raise KeyError KeyError Table definition... db.define_table('payment', Field( 'received_date' , 'date', requires=IS_NOT_EMPTY(), default=request.now.date() , writable=False,comment="*"), Field( 'amount' , 'decimal(6,2)' , default=0.00,requires=IS_NOT_EMPTY() ,writable=False, comment="*"), Field( 'payment_type' , requires=IS_IN_SET(['INVOICE','ACTIVITY']),writable=False,), Field( 'invoice_ref' , 'reference invoice' , default=None , writable=False,), Field( 'activity_ref' , 'reference task' , default=None, writable=False,), Field( 'method' , requires=IS_IN_SET( PAYMENT_METHODS )), Field( 'notes' , 'text',default=None ), format='%(received_date)s %(amount)s ') Function definition... def view_payment(): payment_id=request.args(0) payment=(db.payment[payment_id]) or redirect(error_page) # print info for sanity check p = payment print type(p) print "<view_payment> id:%s amount:%s type:%s inv ref:%s task_ref:%s" %(p.id , p.amount, p.payment_type , p.invoice_ref, p.activity_ref) form=SQLFORM(db.payment,payment) return dict(form=form) Called with .../default/view_payment/1 print output shows the code is retrieving a valid row type and record with id=1... <class 'pydal.objects.Row'> <view_payment> id:1 amount:80.00 type:INVOICE inv ref:1 task_ref:None I have tried as much as I can think of including - dropped/rebuilt the payment table - recreated the record manually - replaced request.args(0) with physical 1 - replaced SQLFORM with crud.update(...) The record does exist as shown here in SQLite <https://lh3.googleusercontent.com/-nJMpBGRB8ac/V-01kiWwB6I/AAAAAAAAAIE/IfpGByy4YrEncNnczZO8NxajwLl1q2iVgCLcB/s1600/SQLFORM%2Bkey%2Berror.png> When I remove the record/id from the SQLFORM call form=SQLFORM(db.payment) return dict(form=form) It opens a create form as expected It just won't accept an id parameter? Can anyone see an obvious problem with the code? Many thanks Peter -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.