[web2py] SQLFORM key error on simple table with one record

2016-09-29 Thread Peter
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" 
, line 
717, in 
  File "/home/peter/web2py/gluon/globals.py", line 417, in 
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" 
, 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 " 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... 

 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








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.


[web2py] SQLFORM key error

2012-08-23 Thread pylix
Here's my model

db = DAL('sqlite://storage.sqlite')
db.define_table('person',
Field('name', requires=IS_NOT_EMPTY()),
Field('phone', requires=IS_NOT_EMPTY()),
Field('address', requires=IS_NOT_EMPTY()),
Field('city', requires=IS_NOT_EMPTY()),
Field('state', requires=IS_IN_SET(['NY' ,'NJ' ,'CN'])),
Field('zip', requires=IS_NOT_EMPTY()),
Field('year', requires=IS_NOT_EMPTY()),
Field('model', requires=IS_NOT_EMPTY()),
Field('make', requires=IS_NOT_EMPTY()),
Field('engine', requires=IS_NOT_EMPTY()),
Field('starts', 'boolean'),
Field('foward', 'boolean'),
Field('reverse', 'boolean'),
Field('complaint', 'text'))

the controller is

def freequote():
form = SQLFORM(db.person)
return dict(form=form)

and the view

{{extend 'layout.html'}}
{{=form}}

I'm getting this error when i try to view the page
type 'exceptions.KeyError' 'person'

Traceback (most recent call last):
File gluon/restricted.py, line 205, in restricted
File /controllers/default.py 
http://127.0.0.1:8000/admin/default/edit/transmission/controllers/default.py, 
line 10, in module
File gluon/globals.py, line 173, in lambda
File /controllers/default.py 
http://127.0.0.1:8000/admin/default/edit/transmission/controllers/default.py, 
line 8, in freequote
File gluon/dal.py, line 6343, in __getattr__
File gluon/dal.py, line 6337, in __getitem__
KeyError: 'person'


not sure why i'm getting a keyerror is the table is defined.

-- 





Re: [web2py] SQLFORM key error

2012-08-23 Thread Bruno Rocha
web2py version??


On Thu, Aug 23, 2012 at 10:00 PM, pylix pyl...@gmail.com wrote:

 Here's my model

 db = DAL('sqlite://storage.sqlite')
 db.define_table('person',
 Field('name', requires=IS_NOT_EMPTY()),
 Field('phone', requires=IS_NOT_EMPTY()),
 Field('address', requires=IS_NOT_EMPTY()),
 Field('city', requires=IS_NOT_EMPTY()),
 Field('state', requires=IS_IN_SET(['NY' ,'NJ' ,'CN'])),
 Field('zip', requires=IS_NOT_EMPTY()),
 Field('year', requires=IS_NOT_EMPTY()),
 Field('model', requires=IS_NOT_EMPTY()),
 Field('make', requires=IS_NOT_EMPTY()),
 Field('engine', requires=IS_NOT_EMPTY()),
 Field('starts', 'boolean'),
 Field('foward', 'boolean'),
 Field('reverse', 'boolean'),
 Field('complaint', 'text'))

 the controller is

 def freequote():
 form = SQLFORM(db.person)
 return dict(form=form)

 and the view

 {{extend 'layout.html'}}
 {{=form}}

 I'm getting this error when i try to view the page
 type 'exceptions.KeyError' 'person'


 Traceback (most recent call last):
 File gluon/restricted.py, line 205, in restricted

 File /controllers/default.py 
 http://127.0.0.1:8000/admin/default/edit/transmission/controllers/default.py,
  line 10, in module
 File gluon/globals.py, line 173, in lambda
 File /controllers/default.py 
 http://127.0.0.1:8000/admin/default/edit/transmission/controllers/default.py,
  line 8, in freequote

 File gluon/dal.py, line 6343, in __getattr__

 File gluon/dal.py, line 6337, in __getitem__

 KeyError: 'person'


 not sure why i'm getting a keyerror is the table is defined.

 --





-- 





Re: [web2py] SQLFORM key error

2012-08-23 Thread pylix
1.99.7 stable i think it's the latest downloaded it recently
but i'm on a windows machine, maybe that's the issue?

On Thursday, August 23, 2012 9:04:41 PM UTC-4, rochacbruno wrote:

 web2py version??


 On Thu, Aug 23, 2012 at 10:00 PM, pylix pyl...@gmail.com javascript:wrote:

 Here's my model

 db = DAL('sqlite://storage.sqlite')
 db.define_table('person',
 Field('name', requires=IS_NOT_EMPTY()),
 Field('phone', requires=IS_NOT_EMPTY()),
 Field('address', requires=IS_NOT_EMPTY()),
 Field('city', requires=IS_NOT_EMPTY()),
 Field('state', requires=IS_IN_SET(['NY' ,'NJ' ,'CN'])),
 Field('zip', requires=IS_NOT_EMPTY()),
 Field('year', requires=IS_NOT_EMPTY()),
 Field('model', requires=IS_NOT_EMPTY()),
 Field('make', requires=IS_NOT_EMPTY()),
 Field('engine', requires=IS_NOT_EMPTY()),
 Field('starts', 'boolean'),
 Field('foward', 'boolean'),
 Field('reverse', 'boolean'),
 Field('complaint', 'text'))

 the controller is

 def freequote():
 form = SQLFORM(db.person)
 return dict(form=form)

 and the view

 {{extend 'layout.html'}}
 {{=form}}

 I'm getting this error when i try to view the page
 type 'exceptions.KeyError' 'person'

 Traceback (most recent call last):
 File gluon/restricted.py, line 205, in restricted


 File /controllers/default.py 
 http://127.0.0.1:8000/admin/default/edit/transmission/controllers/default.py,
  line 10, in module

 File gluon/globals.py, line 173, in lambda

 File /controllers/default.py 
 http://127.0.0.1:8000/admin/default/edit/transmission/controllers/default.py,
  line 8, in freequote


 File gluon/dal.py, line 6343, in __getattr__


 File gluon/dal.py, line 6337, in __getitem__


 KeyError: 'person'


 not sure why i'm getting a keyerror is the table is defined.

 -- 
  
  
  




-- 





Re: [web2py] SQLFORM key error

2012-08-23 Thread Massimo Di Pierro
We have posted some broken web2py version to perform some experiments. You 
may have gotten one of them.  Download it again now. It is a release 
candidate and should be better than 1.99.7.

On Thursday, 23 August 2012 20:17:02 UTC-5, pylix wrote:

 1.99.7 stable i think it's the latest downloaded it recently
 but i'm on a windows machine, maybe that's the issue?

 On Thursday, August 23, 2012 9:04:41 PM UTC-4, rochacbruno wrote:

 web2py version??


 On Thu, Aug 23, 2012 at 10:00 PM, pylix pyl...@gmail.com wrote:

 Here's my model

 db = DAL('sqlite://storage.sqlite')
 db.define_table('person',
 Field('name', requires=IS_NOT_EMPTY()),
 Field('phone', requires=IS_NOT_EMPTY()),
 Field('address', requires=IS_NOT_EMPTY()),
 Field('city', requires=IS_NOT_EMPTY()),
 Field('state', requires=IS_IN_SET(['NY' ,'NJ' ,'CN'])),
 Field('zip', requires=IS_NOT_EMPTY()),
 Field('year', requires=IS_NOT_EMPTY()),
 Field('model', requires=IS_NOT_EMPTY()),
 Field('make', requires=IS_NOT_EMPTY()),
 Field('engine', requires=IS_NOT_EMPTY()),
 Field('starts', 'boolean'),
 Field('foward', 'boolean'),
 Field('reverse', 'boolean'),
 Field('complaint', 'text'))

 the controller is

 def freequote():
 form = SQLFORM(db.person)
 return dict(form=form)

 and the view

 {{extend 'layout.html'}}
 {{=form}}

 I'm getting this error when i try to view the page
 type 'exceptions.KeyError' 'person'

 Traceback (most recent call last):
 File gluon/restricted.py, line 205, in restricted


 File /controllers/default.py 
 http://127.0.0.1:8000/admin/default/edit/transmission/controllers/default.py,
  line 10, in module

 File gluon/globals.py, line 173, in lambda

 File /controllers/default.py 
 http://127.0.0.1:8000/admin/default/edit/transmission/controllers/default.py,
  line 8, in freequote


 File gluon/dal.py, line 6343, in __getattr__


 File gluon/dal.py, line 6337, in __getitem__


 KeyError: 'person'


 not sure why i'm getting a keyerror is the table is defined.

 -- 
  
  
  




-- 





Re: [web2py] SQLFORM key error

2012-08-23 Thread pylix
I'm an idiot... 
the software works fine
I just forgot to name the
model appropriately(it wasn't named like the controller).
sorry for using up your
resources on this silly mistake
I'll try to troubleshoot more own
my own in the future.

On Thursday, August 23, 2012 9:49:14 PM UTC-4, Massimo Di Pierro wrote:

 We have posted some broken web2py version to perform some experiments. You 
 may have gotten one of them.  Download it again now. It is a release 
 candidate and should be better than 1.99.7.

 On Thursday, 23 August 2012 20:17:02 UTC-5, pylix wrote:

 1.99.7 stable i think it's the latest downloaded it recently
 but i'm on a windows machine, maybe that's the issue?

 On Thursday, August 23, 2012 9:04:41 PM UTC-4, rochacbruno wrote:

 web2py version??


 On Thu, Aug 23, 2012 at 10:00 PM, pylix pyl...@gmail.com wrote:

 Here's my model

 db = DAL('sqlite://storage.sqlite')
 db.define_table('person',
 Field('name', requires=IS_NOT_EMPTY()),
 Field('phone', requires=IS_NOT_EMPTY()),
 Field('address', requires=IS_NOT_EMPTY()),
 Field('city', requires=IS_NOT_EMPTY()),
 Field('state', requires=IS_IN_SET(['NY' ,'NJ' ,'CN'])),
 Field('zip', requires=IS_NOT_EMPTY()),
 Field('year', requires=IS_NOT_EMPTY()),
 Field('model', requires=IS_NOT_EMPTY()),
 Field('make', requires=IS_NOT_EMPTY()),
 Field('engine', requires=IS_NOT_EMPTY()),
 Field('starts', 'boolean'),
 Field('foward', 'boolean'),
 Field('reverse', 'boolean'),
 Field('complaint', 'text'))

 the controller is

 def freequote():
 form = SQLFORM(db.person)
 return dict(form=form)

 and the view

 {{extend 'layout.html'}}
 {{=form}}

 I'm getting this error when i try to view the page
 type 'exceptions.KeyError' 'person'

 Traceback (most recent call last):
 File gluon/restricted.py, line 205, in restricted


 File /controllers/default.py 
 http://127.0.0.1:8000/admin/default/edit/transmission/controllers/default.py,
  line 10, in module

 File gluon/globals.py, line 173, in lambda

 File /controllers/default.py 
 http://127.0.0.1:8000/admin/default/edit/transmission/controllers/default.py,
  line 8, in freequote


 File gluon/dal.py, line 6343, in __getattr__


 File gluon/dal.py, line 6337, in __getitem__


 KeyError: 'person'


 not sure why i'm getting a keyerror is the table is defined.

 -- 
  
  
  




--