Hi James, Yes, why don't you send a simple app that replicates the errors you are seeing. A few comments below...
On Monday, April 4, 2011 4:22:22 AM UTC-4, james c. wrote: > thanks, james c. > > > ================ > Late Friday, while grasping at things like string output conversions > as possible solutions, I found alternate dictionary iterative methods > - after which I had a solution working in about two minutes. It just > worked. here it is: > > cpp=db(db.customer_names.id==name_index).select().as_dict() Note, a select() returns a Rows object, but as_dict() should be applied to a Row object (though perhaps it works if the Rows object includes only one Row). I think you should either use as_list (to get a list containing a single dictionary for the row), or use .first().as_dict(). > db(db.customer_names.id==names_index).select('name').first().name > > I could get something similar to this running in the console. My > web2py is using the default Python254. With Python254, adding first() > or .name, results in a compile or syntax error. The least common parts > of this code that I got to work is: > > pcc=db(db.customer_names.id==names_index).select('name') > > this is returned through to the view as return > dict(display_name=pcc...) and in the view {{=display_name}}. In this > case I believe the functions are returning html because the resulting > web page output is formated such as: > > NAME > -------------- > The Big Note, in your example above, 'display_name' is a Rows object. When you write a Rows object in a view, web2py converts it to a SQLTABLE object, which is rendered as an HTML table as above. This is explained here: http://web2py.com/book/default/chapter/06#Serializing-Rows-in-Views > > I could get code working (in a manner similar to what you suggest) with > the three versions of python in console to retrieve specific > dictionary items, but in Web2py the system seems to not be recognizing > these returned items as lists or as dictionaries. What do you mean you could get it working in the console? Are you saying you ran web2py in shell mode, and it worked, or you were just playing around with lists and dictionaries in a Python shell, but not using any web2py objects? Anthony