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 <linux...@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 <valq7...@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+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.

Reply via email to