Re: [web2py] Re: DAL issues ....

2018-12-06 Thread Jim S
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'}}
> 
>
>  onclick="location.href='{{=URL('index')}}'"/>
>
> HOME
>
> Input form
> {{=form}}
> Submitted variables
> {{=BEAUTIFY(request.vars)}}
> {{=(request.vars)}}
>
> Company vars: {{=(request.vars['Company'])}}
> Company session: {{=(session.company)}}
> session data: {{=(session.company_data)}}
>
> Will Display The following:
> (top of form omitted ...)
> . Submitted variables 
> Company : 
> 5
> password : 
> makeit1
> username : 
> be...@linux4ms.net 
> ', 'Company': '5', 
> 'password': 'makeit1', '_formkey': '65ee8396-aac0-4b5c-a255-00be7e7b01ca', 
> '_formname': 'no_table/create'}> Company vars: 5 Company session: 5 session 
> data: 
>
> ___
>
> 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
>  '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" 
> , line 98, 
> in 
>   File "/data/web2py/web2py/gluon/globals.py", line 421, in 
> self._caller = lambda f: f()
>   File "/data/web2py/web2py/applications/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  > 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 .
>> 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.


Re: [web2py] Re: DAL issues ....

2018-12-06 Thread Ben Duncan
Here is something strange as well - working thru the web2py console,
everything works:

[web2py@su-postgres-ben-3 web2py]$ python ./web2py.py -S Mec -M
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2018
Version 2.17.2-stable+timestamp.2018.10.06.18.54.02
Database drivers available: psycopg2, pymysql, imaplib, sqlite3, pg8000,
pyodbc
WARNING:web2py:import IPython error; use default python shell
Python 2.7.13 (default, Feb  8 2017, 06:30:30)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> session.company_id = '5'
>>> Company_ID = session.company_id
>>> print Company_ID
5
>>> DbRows =
db(db.company.company_number==Company_ID).select(db.company.company_name).first()
>>> type(DbRows['company_name'])

>>> DbRows['company_name']
'Number 5 Company'
>>> session.company_data = DbRows
>>> type(DbRows['company_name'])

>>> print session.company_data['company_name']
Number 5 Company
>>>type(DbRows)

>>>





*Ben Duncan*
DBA / Chief Software Architect
Mississippi State Supreme Court
Electronic Filing Division


On Thu, Dec 6, 2018 at 12:22 PM 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'}}
> 
>
>  onclick="location.href='{{=URL('index')}}'"/>
>
> HOME
>
> Input form
> {{=form}}
> Submitted variables
> {{=BEAUTIFY(request.vars)}}
> {{=(request.vars)}}
>
> Company vars: {{=(request.vars['Company'])}}
> Company session: {{=(session.company)}}
> session data: {{=(session.company_data)}}
>
> Will Display The following:
> (top of form omitted ...)
> . Submitted variables
> Company :
> 5
> password :
> makeit1
> username :
> b...@linux4ms.net
>  'makeit1', '_formkey': '65ee8396-aac0-4b5c-a255-00be7e7b01ca', '_formname':
> 'no_table/create'}> Company vars: 5 Company session: 5 session data:  {'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
>  '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" 
> , line 98, 
> in 
>   File "/data/web2py/web2py/gluon/globals.py", line 421, in 
> self._caller = lambda f: f()
>   File "/data/web2py/web2py/applications/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 
> 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 

Re: [web2py] Re: DAL issues ....

2018-12-06 Thread Ben Duncan
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'}}




HOME

Input form
{{=form}}
Submitted variables
{{=BEAUTIFY(request.vars)}}
{{=(request.vars)}}

Company vars: {{=(request.vars['Company'])}}
Company session: {{=(session.company)}}
session data: {{=(session.company_data)}}

Will Display The following:
(top of form omitted ...)
. Submitted variables
Company :
5
password :
makeit1
username :
b...@linux4ms.net
 Company vars: 5 Company session: 5 session data: 
___

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
 '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"
,
line 98, in 
  File "/data/web2py/web2py/gluon/globals.py", line 421, in 
self._caller = lambda f: f()
  File "/data/web2py/web2py/applications/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  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+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.