Cool. Sure, go ahead and post the example app. If you use the newer forum 
interface to reply (
https://groups.google.com/forum/?fromgroups#!forum/web2py), there's a file 
attachment feature that lets you upload a file with your post.
 
Anthony

On Tuesday, April 5, 2011 1:06:09 AM UTC-4, james c. wrote:

> Thanks Anthony, 
>
> Your last note fixed it!  Works just fine with: 
>
> cname=db(db.customer_names.id==name_index).select().first().as_dict() 
> ['name'] 
>
> Also, on your most recent question - no I was not using web2py in 
> shell mode. I was playing around, in a console running python 254, 
> with lists and dictionaries in a from the results I was seeing in 
> web2py. The example app is done. If you would still like me to send 
> it, let me know where to post it or email 
>
> thanks again, James C. 
>
>
>
> On Apr 4, 8:08 am, Anthony <abas...@gmail.com> wrote: 
> > 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

Reply via email to