Recently I had the opportunity to take a look at the structure of web2py, and although I have some experience with Django and, moreover, with simple Python, I could not understand the meaning of the Query system that web2py uses.
Take this example from web2py book
db = DAL('sqlite://storage.db')
myquery = (db.mytable.myfield > 'A')
myset = db(myquery)
rows = myset.select()
for row in rows:
print row.myfield
In a SO comment, the web2py author says that he (db.mytable.myfield > 'A')does not evaluate the True / False value directly and is actually evaluated for each row at the time of the selection. I understand that this allows you to use these expressions as query objects and even combine them.
I tried to find the answer to this online, but could not, so here is my question: how do these query expressions not evaluate True / False right away? Why is the value of myquery not, say, True? What Python function, which is probably missing, allows you to work?
source
share