Thanks Ben On Thu, Dec 6, 2018 at 3:42 PM Ben Duncan <linux...@gmail.com> wrote:
> Controller Code: > > def company_login(): > > 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 = session.company > > if session.company : > DbRows = db(db.company.company_number==Company_ID).select().first() > session.company_data = DbRows > session.company_name = DbRows.company_name > session.company_ap_aging = DbRows. > > return dict(form=form) > > The reason I need this setup is that this is the Company Record that > controls all aspects of > the system (see ap_apaging_days). It also controls what sub-apps are on > and off ... > > > > *Ben Duncan* > DBA / Chief Software Architect > Mississippi State Supreme Court > Electronic Filing Division > > > On Thu, Dec 6, 2018 at 2:59 PM Jim S <ato.st...@gmail.com> wrote: > >> I'd love to see the final controller code if you have the time? >> >> Also, I'm curious as to why you're putting all this in the session. Why >> not just pass it in the dict being returned to the view? >> >> -Jim >> >> On Thursday, December 6, 2018 at 2:46:22 PM UTC-6, Ben Duncan wrote: >>> >>> Ok, YOU GUYS are awesome ....... >>> Your replies gave me the insight I needed !!!!!!!!! >>> >>> Here is the explanation: >>> >>> A: in the database, the passes were for the "lookup" in the >>> SQLFORM.factory >>> SO there was the confusion there ... >>> >>> B: It seems there is a 2 passes thru the controller (which this group >>> gave me the hint at it) >>> The failure was at the first pass when nothing was set ... >>> putting this in: >>> >>> if session.company : >>> DbRows = >>> db(db.company.company_number==Company_ID).select(db.company.company_name).first() >>> session.company_data = DbRows >>> session.company_name = DbRows.company_name >>> >>> Allowed me to PASS unharmed and get what I needed. >>> >>> THANKS Again, group .... >>> >>> >>> . >>> *Ben Duncan* >>> DBA / Chief Software Architect >>> Mississippi State Supreme Court >>> Electronic Filing Division >>> >>> >>> On Thu, Dec 6, 2018 at 2:21 PM Ben Duncan <linu...@gmail.com> wrote: >>> >>>> The request.vars get set from the SQL form in the controller.... >>>> Removed all the COMMENTS, and in the controller put a print and changed >>>> the code: >>>> >>>> DbRows = >>>> db(db.company.company_number==Company_ID).select(db.company.company_name).first() >>>> print DbRows['company_name'] >>>> session.company_data = DbRows >>>> return dict(form=form,DbRows=DbRows) >>>> >>>> And still getting a failure now on the print line ... >>>> >>>> Ticket ID >>>> >>>> 10.13.69.144.2018-12-06.13-53-08.f35db77f-72f8-4749-82e9-90eda4c32141 >>>> <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 >>>> 101, 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 >>>> print DbRows['company_name'] >>>> TypeError: 'NoneType' object has no attribute '__getitem__' >>>> >>>> >>>> >>>> It's very strange how : >>>> session.company_data = DbRows >>>> Gets passed. >>>> >>>> However, looking at the postgres logs: >>>> 2018-12-06 14:18:31.482 CST SessId: 5c0981bd.6e70 TrxId: 0>LOG: >>>> statement: SELECT "company"."company_name", "company"."company_number" FROM >>>> "company" WHERE ("company"."company_number" IS NOT NULL) ORDER BY >>>> "company"."company_name", "company"."company_number"; >>>> < 2018-12-06 14:18:31.488 CST SessId: 5c0981bd.6e70 TrxId: 0>LOG: >>>> statement: SELECT "company"."company_name" FROM "company" WHERE >>>> ("company"."company_number" IS NULL); >>>> < 2018-12-06 14:18:31.505 CST SessId: 5c0981bd.6e70 TrxId: 0>LOG: >>>> statement: COMMIT >>>> < 2018-12-06 14:18:35.282 CST SessId: 5c0981bd.6e70 TrxId: 0>LOG: >>>> statement: BEGIN >>>> < 2018-12-06 14:18:35.282 CST SessId: 5c0981bd.6e70 TrxId: 0>LOG: >>>> statement: SELECT 1; >>>> < 2018-12-06 14:18:35.475 CST SessId: 5c0981bd.6e70 TrxId: 0>LOG: >>>> statement: SELECT "company"."company_name", "company"."company_number" FROM >>>> "company" WHERE ("company"."company_number" IS NOT NULL) ORDER BY >>>> "company"."company_name", "company"."company_number"; >>>> < 2018-12-06 14:18:35.485 CST SessId: 5c0981bd.6e70 TrxId: 0>LOG: >>>> statement: SELECT "company"."company_name" FROM "company" WHERE >>>> ("company"."company_number" = 13); >>>> < 2018-12-06 14:18:35.505 CST SessId: 5c0981bd.6e70 TrxId: 0>LOG: >>>> statement: COMMIT >>>> >>>> It seems to be making 2 passes thru the DB >>>> >>>> Allows the the session variable to be set >>>> *Ben Duncan* >>>> DBA / Chief Software Architect >>>> Mississippi State Supreme Court >>>> Electronic Filing Division >>>> >>>> >>>> On Thu, Dec 6, 2018 at 1:30 PM Val K <valq...@gmail.com> wrote: >>>> >>>>> Maybe I don't understand something, but I think that when the >>>>> controller is requested for the first time there is no any request.vars >>>>> and >>>>> request.vars['Company'] too. Just in case: form.process() doesn't >>>>> interrupt >>>>> controller execution >>>>> >>>>> -- >>>>> 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. >>>>> 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. >> > -- > 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 a topic in the > Google Groups "web2py-users" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/web2py/o48pZhY7dYM/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > web2py+unsubscr...@googlegroups.com. > 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.