It looks like the second line of your view if reassigning something else to session.company. I don't believe the HTML comment tags are not going to prevent web2py from executing that statement.
-Jim On Thursday, December 6, 2018 at 12:22:30 PM UTC-6, Ben Duncan wrote: > > Well I was thinking that, BUT: I'm ALMOST convinced there is a bug in the > latest web2py: > > CODE > ------------------------------------------------------------------------------------------------------------------------------ > Snippet of controllers/default.py > > session.company = request.vars['Company'] > Company_ID = "This is a %s of type %s " % (session.company, > type(session.company)) > Company_ID = session.company > > DbRows = > db(db.company.company_number==Company_ID).select(db.company.company_name).first() > # Co_Name = DbRows['company_name'] > > session.company_data = DbRows > > From view/default/company_login.html: > {{extend 'layout.html'}} > <!-- {{session.company = request.vars['Company']}} --> > > <INPUT type="button" value="HOME" > onclick="location.href='{{=URL('index')}}'"/> > > <a href="{{=URL('index')}}">HOME</a> > > <h4>Input form</h4> > {{=form}} > <h4 style="margin:0;">Submitted variables</h4> > {{=BEAUTIFY(request.vars)}} > {{=(request.vars)}} > > <h4 style="margin:0;">Company vars: {{=(request.vars['Company'])}}</h4> > <h4 style="margin:0;">Company session: {{=(session.company)}}</h4> > <h4 style="margin:0;">session data: {{=(session.company_data)}}</h4> > > Will Display The following: > (top of form omitted ...) > ..... Submitted variables > Company : > 5 > password : > makeit1 > username : > be...@linux4ms.net <javascript:> > <Storage {'username': 'be...@linux4ms.net <javascript:>', 'Company': '5', > 'password': 'makeit1', '_formkey': '65ee8396-aac0-4b5c-a255-00be7e7b01ca', > '_formname': 'no_table/create'}> Company vars: 5 Company session: 5 session > data: <Row {'company_name': 'Number 5 Company'}> > > ___________________________________________________________________________________________________________________________________ > > However, any type of referencing or attempt to do anything with either > session.company_date or DbRows > always gives a "Nonetype" error of various subtypes (such as __getitem__) > > Uncommenting the controller code of "# Co_Name = DbRows['company_name']" > gives the error: > > Ticket ID > > 10.13.69.144.2018-12-06.12-17-59.81fd7ae1-6523-47ad-94c7-7b1b480179bd > <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 98, > 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 84, > in company_login > Co_Name = DbRows['company_name'] > TypeError: 'NoneType' object has no attribute '__getitem__' > > > As one can see , the Row item exists, it just seems there is no way to get > to it ... > > Any other ideas ? > > > *Ben Duncan* > DBA / Chief Software Architect > Mississippi State Supreme Court > Electronic Filing Division > > > On Thu, Dec 6, 2018 at 9:09 AM Leonel Câmara <leonel...@gmail.com > <javascript:>> wrote: > >> What's happening here is that DbRows can become None in this line >> >> DbRows = >> db(db.company.company_number==Company_ID).select(db.company.company_name).first() >> >> So when you do DbRows['company_name'] you can get that error. >> >> Basically you need to check if DbRows is None and raise HTTP(404) >> >> -- >> 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+un...@googlegroups.com <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > -- 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.