> SQLObject is "lazy" to evaluate results, so you might benefit from a more
> straighforward approach:
>
>       results = model.Books.select()
>
>       if only_read:
>               results = results.filter(onlyRead = True)
>       if not_borrowed:
>               results = results.filter(notBorrowed = True)
>
>       return (books=results)
>
>
> This will prepare to retrieve all books.  If any of the two filters is
> true, then it will be applied to the query (as you can see, both can be
> true at once).
>
> The query will be performed only when you iterate over the results or when
> you ask to make it a list, for example.
>
> I consider this a much cleaner approach to build "AND" filters.  You can
> expand this into "OR" as well.

I totally admit that filter is cool, matter of fact I do use it myself. But 
are you sure about the OR? How so?

Diez

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to