Python 2.7.12
web2py 2.14 stable
--call to controller developed by javascript
--call to controller. Captured by Chrome inspect
GET "http://127.0.0.1:8000/default/FoldBe.html?operation=get&id=%23"
--controller default.py
FoldBe():
vars = dict(request.vars)
print type(vars)
#<type 'dict'>
print vars
#{'operation': 'get', 'id': '#'}
for i in vars:
print i
#operation
#id
#print i.id
print vars.id
#ERRORS!!! stating. What gives?
#<type 'exceptions.AttributeError'> 'dict' object has no attribute 'id'
But the 'vars' dict obviously is a 'dict' and obviously has an 'id' attribute
If i remark out print vars.id
the view renders in the browser & no errors indicated as you would expect.
If I allow print i.id
to execute the error is:
<type 'exceptions.AttributeError'> 'str' object has no attribute 'id'
What gives?
I have other methods in this controller and other controllers where this isn't a problem.
You should access dictionary keys by name, so try
vars['id']
instead ofvars.id
.