Can you try passing DbRows to your view and see if that works? return dict(form=form, DbRows=DbRows)
Or, throw a print statement in there before session.company_name = DbRows['company_name'] to see if DbRows['company_name'] has a value before sending to the view? -Jim On Thursday, December 6, 2018 at 7:42:27 AM UTC-6, Ben Duncan wrote: > > How can something that seems so simple, be so hard? > > I can't seem to get a SINGLE field from the database from DAL: > > First is the Error Message (Or on of the many types - but the latest one), > then the code > > What AM I doing wrong here ? > > Als always, thanks ... > > Error Message: > Error ticket for "Mec" Ticket ID > > 10.13.69.144.2018-12-06.07-32-29.8fda8fd6-fe14-47f4-b508-14ce2346465e > <type 'exceptions.TypeError'> 'NoneType' object has no attribute > '__getitem__' Version > web2py™ Version 2.17.2-stable+timestamp.2018.10.06.18.54.02 > Python Python 2.7.13: /usr/bin/python (prefix: /opt/rh/python27/root/usr) > Traceback > > 1. > 2. > 3. > 4. > 5. > 6. > 7. > 8. > 9. > 10. > > Traceback (most recent call last): > File "/data/web2py/web2py/gluon/restricted.py", line 219, in restricted > exec(ccode, environment) > File "/data/web2py/web2py/applications/Mec/controllers/default.py" > <https://10.13.70.47/admin/default/edit/Mec/controllers/default.py>, line 96, > in <module> > File "/data/web2py/web2py/gluon/globals.py", line 421, in <lambda> > self._caller = lambda f: f() > File "/data/web2py/web2py/applications/Mec/controllers/default.py" > <https://10.13.70.47/admin/default/edit/Mec/controllers/default.py>, line 87, > in company_login > session.company_name = DbRows['company_name'] > TypeError: 'NoneType' object has no attribute '__getitem__' > > Error snapshot [image: help] > <https://10.13.70.47/admin/default/ticket/Mec/10.13.69.144.2018-12-06.07-32-29.8fda8fd6-fe14-47f4-b508-14ce2346465e#> > > > <type 'exceptions.TypeError'>('NoneType' object has no attribute > '__getitem__') > -------------------- Code Here > -------------------------------------------------- > Ok - Code for controller/default.py > > def company_login(): > company.company_name,orderby=db.company.company_name) form = > SQLFORM.factory( > Field('username', label = 'User Name', requires=IS_NOT_EMPTY()), > Field('password', 'password', label = > "Password",requires=IS_NOT_EMPTY()), > Field('Company', label = 'Court ID', > > requires=IS_IN_DB(db,db.company.company_number,'%(company_name)s')), > submit_button=' Login ', > ) > > if form.process().accepted: > response.flash = 'form accepted' > elif form.errors: > response.flash = T('form has errors') > > session.company = request.vars['Company'] > Company_ID = request.vars['Company'] > DbRows = > db(db.company.company_number==Company_ID).select(db.company.company_name).first() > session.company_name = DbRows['company_name'] > > return dict(form=form) > > > > > > Thanks again ... > > > *Ben Duncan* > DBA / Chief Software Architect > Mississippi State Supreme Court > Electronic Filing Division > -- 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.