I'm doing a database-heavy app, and one of the things which has bothered me a little about web2py is that I can't depend on the Row object generated by a query. Sometimes it has a key for each table of a multi-table join, but if the query comes from a single table, there is no table key. Fine, I'm good with that. It leads to defensive programming on my port like this:
val = None if not k.db_name else row[k.db_name] if not k.table else row[k. table][k.db_name] In this case, I'm testing for a value of row with just the field name, if that fails then I try the field and the table. This used to work in the good old days because Row would return None for any item not in its dictionary. Now it fails. In my particular example, the field name k.db_name does not exist in the row, but the compound row[db_name][k.table] does. The code never gets that far, returning an exception on the k[db_name] attempt. Now the Row class specifically tests to see if the key is in the Row and then throws an expiation at the end if the key isn't found. When Row was based on Storage it did not behave this way, from my recollection. I'm competent enough to make my code even more defensive, bracketing with try:except: and what not. I'm just curious why the change was made in a behavior that may previously been relied upon as a "feature", in essence now declaring it as a "bug" and "fixing" it. -- Joe -- 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.