there's a bit of short-circuit in this.....

small recap:
- SQLFORM.grid() takes a query, i.e. db(set), i.e. just what you'd like to 
display without the .select() part
- belongs() is a method to build up a condition, that takes either a list 
of values, or a subselect, i.e. a full db(set).select(thevalueyouneed)
- if you put a select() on the "thing" you pass to the grid, you should get 
the results you want

so, let's go step-by-step

1. your CamelCased DontDisplayThisPersonQuery needs to be "augmented"... it 
needs to return a list of ids that you want to exclude... you should have 
it in this form: db(someconditions)._select(db.auth_user.id) <-- mind the 
_select() part that makes it a subselect elegible to be passed as a 
belongs() argument
2. try final the query first with .select(), such as db(~
db.auth_user.id.belongs(theaugmented)).select()
3. once confirmed that 2. returns what you want, strip the select() part 
and pass it to the grid, such as SQLFORM.grid(db(~
db.auth_user.id.belongs(theaugmented)))


On Sunday, March 1, 2015 at 10:50:53 PM UTC+1, Alex Glaros wrote:
>
> get this error
>
> Query Not Supported: no such column: BlockedConnection.blockingPerson
>
> when trying to exclude "blocked" people in social network app
>
> doNotDisplayThisPersonQuery = ((db.auth_user.id == db.BlockedConnection.
> blockingPerson) & (db.BlockedConnection.blockedPerson == auth.user_id))
>
> query = ~db.auth_user.id.belongs([doNotDisplayThisPersonQuery])
>
> grid = SQLFORM.grid(query, fields=[db.BlockedConnection.blockingPerson, db
> .BlockedConnection.blockedPerson, db.auth_user.first_name, db.auth_user.
> last_name, db.auth_user.personMiddleName, db.auth_user.currentPosition, db
> .auth_user.summarySelfDescription, db.auth_user.keyWords])
>
> any ideas on how to fix or write smarter function?
>
> thanks
>
> Alex Glaros
>
>
>
>
>
>

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