Assuming there is some reason you can't move the additional query 
conditions to the database and you must do the filtering in Python (e.g., 
the query is complex or you need to filter the same set of rows in multiple 
ways), you can use the .find() method 
<http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#find--exclude--sort>
 
of the Rows object:

primary_residence_rows = all_rows.find(lambda r: r.primary_residence == True
)

Anthony

On Tuesday, November 3, 2015 at 8:53:49 AM UTC-5, Mark Billion wrote:
>
> This seems ugly:
> foo = db(db.xxx.id==x.id).select()
>         for a in foo:
>             if a.primary_residence == True:
>                 nine_b_count = 1
> ......
> Is there a way for me to select only the elements of foo that meet the 
> secondary test.  Something like foo.select(a.primary_residence == True) #I 
> know this is wrong
>
>

-- 
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