On Tuesday, September 16, 2014 4:05:12 PM UTC-4, Yi Liu wrote:
>
> web2py Shell 2.9.5-stable+timestamp.2014.03.16.02.35.39
> In [1] : tos = db(db.auth_criteria.toSend ==1).select()
>
> In [2] : tos
> <Rows (1)>
>
> In [3] : for row in tos:
>     print row.user_id.email
>
> Traceback (most recent call last):
>   File "/Users/LaViez/Documents/Python/web2py/gluon/contrib/shell.py", 
> line 234, in run
>     exec compiled in statement_module.__dict__
>   File "<string>", line 2, in <module>
> AttributeError: 'long' object has no attribute 'email'
>
>
I think this is a quirk of the web-based shell. You should be able to do:

db(db.auth_criteria.toSend ==1).select().first().user_id.email
 
But if you first store the Rows object and then access attributes of a row, 
the dal.Reference objects will have been converted to simple Long objects, 
and the recursive select will not work. It should work fine in a console 
based shell as well as standard app code.

Btw, I find some inconsistency in the book 6th edition.
>
> In the Overview section:
>
> db.post.image_id.requires = IS_IN_DB(db, db.image.id, '%(title)s')
>
>
> But in DAL section:
>
> db.thing.owner_id.requires = IS_IN_DB(db,'person.uuid','%(name)s')
>
>
It's not an inconsistency -- just two different allowed argument types for 
the second argument (either a field object, or its string representation).

Anthony

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to