1) db is your instance of the DAL class. A class in python can have a __call__ method. If it does, instances of that class can be called like functions. Which is what your doing here with db(...).
In this case the DAL's *__call__ *takes a query or nothing and returns a *Set *(not a python set, it's a DAL class). To make this query is why you have the second db. There's another method in the DAL called *__getattr__ *which allows you to get the tables from the DAL defined with *define_table *by using dot notation. So what you're doing here is ask the DAL instance to give you the table category. So now we know what this means: my_set = db(db.category) *You're asking for a Set with the table category.* *select* is a method of *Set* which pretty much is equivalent to SQL's select and returns *Rows*. Which is what you then do with: my_set.select(orderby=db.category.name) This can be simplified by simply calling select on the returning Set immediately so you don't need a variable for the set if you just want the Rows. categories = db(db.category).select(orderby=db.category.name) In this case, on the orderby, first you get the table from db using getattr and then you get the *Field*, which you want to use to order, from the table. That said, you don't need to know any of this, just learn the DAL's syntax like Anthony said. -- 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.