dal retrieve one element from auth_user results in exception when none found

62 views
Skip to first unread message

Boris Aguilar

unread,
Feb 4, 2014, 9:59:04 AM2/4/14
to web...@googlegroups.com
In web2py~2.6 i used to rely on the following to check if an administrative user existed in database:

a = db.auth_user(db.auth_user.username == 'admin') if a was None then the user wasn't in the database

Now in latest version 2.8.2-stable+timestamp.2013.11.28.13.54.07 I'm getting a type error exception:

<type 'exceptions.TypeError'> 'NoneType' object is not iterable

Traceback (most recent call last):
File "/home/boris/Work/deploy-web2py-local/gluon/restricted.py", line 217, in restricted
exec ccode in environment
File "/home/boris/Work/deploy-web2py-local/applications/cpfecys/models/db.py", line 70, in <module>
a = db.auth_user(db.auth_user.username == 'admin')
File "/home/boris/Work/deploy-web2py-local/gluon/dal.py", line 8829, in __call__
limitby=(0,1),for_update=for_update, orderby=orderby, orderby_on_limitby=False).first()
File "/home/boris/Work/deploy-web2py-local/gluon/dal.py", line 10335, in select
return adapter.select(self.query,fields,attributes)
File "/home/boris/Work/deploy-web2py-local/gluon/dal.py", line 1831, in select
return self._select_aux(sql,fields,attributes)
File "/home/boris/Work/deploy-web2py-local/gluon/dal.py", line 1812, in _select_aux
return processor(rows,fields,self._colnames,cacheable=cacheable)
File "/home/boris/Work/deploy-web2py-local/gluon/dal.py", line 2173, in parse
for (i,row) in enumerate(rows):
TypeError: 'NoneType' object is not iterable

Massimo Di Pierro

unread,
Feb 4, 2014, 10:30:25 AM2/4/14
to web...@googlegroups.com
Should have been:

a = db.auth_user(username = 'admin')

Anthony

unread,
Feb 4, 2014, 10:37:08 AM2/4/14
to web...@googlegroups.com
On Tuesday, February 4, 2014 10:30:25 AM UTC-5, Massimo Di Pierro wrote:
Should have been:

a = db.auth_user(username = 'admin')

The __call__ method of Table can also take a query as the first argument, so the original version should work as well (in fact, it works when I try it, on a slightly more recent version than Boris).

Anthony

Boris Aramis Aguilar Rodríguez

unread,
Feb 4, 2014, 10:57:28 AM2/4/14
to web...@googlegroups.com
Everything is fine... it was a mistake on my behalf sorry :S it seems that i pulled some pre-compiled pyc stuff from a partner im working with that made some weird side effects; now all .pyc files are in my gitignore :)

Thanks!

Boris Aramis Aguilar Rodríguez
 Technology Projects Entrepreneur
 IT Services
 (502) 5633 1847



2014-02-04 Anthony <abas...@gmail.com>:

--
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/PQTTd-RWQEM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Dave S

unread,
Feb 4, 2014, 3:15:54 PM2/4/14
to web...@googlegroups.com, m...@borisaguilar.com
On Tuesday, February 4, 2014 7:57:28 AM UTC-8, Boris Aramis Aguilar Rodríguez wrote:
now all .pyc files are in my gitignore :)

Wisdom of the ages!

/dps

Reply all
Reply to author
Forward
0 new messages