Are you saying that 
db(db.customer_names.id==names.index).select('name').first().name does 
not return just the name? Can you show your model code?
 
Also, if you use as_list, you get a list of dictionaries (one dictionary per 
Row in the Rows object). If there is only one Row, then there is only one 
dictionary in the list, and therefore the maximum index of the list will be 
0. If you try current_customer_name[2], it's looking for the third 
dictionary in the list (i.e., the third Row), which of course does not 
exist. The way you have defined current_customer_name, I think the actual 
name should be current_customer_name[0]['name'] (the [0] gets you the first 
dictionary in the list, and the ['name'] gets you the value associated with 
the 'name' key in that dictionary). But again, you shouldn't have to do it 
that way -- the query above should return the name directly without using 
as_list.
 
Anthony

On Friday, April 1, 2011 9:20:26 PM UTC-4, james c. wrote:

> Thanks Denes, 
>
>
> Thank you Denes for your recommendations. 
>
> I've seen documentation leading me to believe that most of this here 
> should work. But it doesn't. 'Which reminds me that I have Python 2.6x 
> installed and when I downloaded my current version, Version 1.91.6 
> (2011-01-03 17:55:14), there was a red 5 in the requirements Python 
> 2.5x. It appears that many folks are now using 2.6x. I am going to 
> upgrade and hope that addresses my issues. If anyone sees anything 
> here or has more ideas I would appreciate the help or pointers to 
> documentation. Thanks, James C. 
>
>
> This is a very simple little test app for which I am implementing this 
> very limited function, described here, working. I think the 
> recommendation below should work. I also think that the use 
> of .as_list() approach should work (however, there exists one 
> additional character between the 'xoxoxo',  characters which define 
> the list - this may be confusing this approach.) 
>
>
> I Tried both recommendations without any good results. The first 
> recommendation is close to what I found in the documentation - neither 
> would run. In either case the changes would not get beyond the editor. 
> I could not find any documentation close to the second recommendation. 
> The syntax might be wrong but could not find any further information 
> to support that conclusion. After much lack of progress I tried a more 
> direct approach using .as_list() The query I'm using and described 
> earlier returns only one field, and that is customer name along with a 
> database descriptive header.  I tried the following in the controller: 
>
>  db(db.customer_names.id==names.index).select('name') 
> current_c_name = db(db.customer_names.id==name_index).select('name') 
> current_customer_name = current_c_name.as_list() 
> display_name = current_customer_name[2] 
> return dict(display_name,... 
>
> in view: 
>
> {{=display_name}} is also defined earlier with a default value. If 
> just the entire 3 element "list" is displayed through 
> {{=display_name}} it looks like: 
>
>  [{'_extra': {'name': u'The Big Company'}}] 
>
> This goes wrong when trying to index the list 
> current_customer_name[2]. What ever index is specified an index out of 
> range error is returned. 
>
>
>
>
> On Apr 1, 1:11 pm, DenesL <dene...@yahoo.ca> wrote: 
> > On Apr 1, 3:24 pm, "james c." <james....@gmail.com> wrote: 
> > 
> > > This is probably simple but I can't find in the documentation or 
> > > recognize anything posted on this. I have a primary database including 
> > > fields which entries must be members of other databases - this is 
> > > enforced through the primary database definition and select lists 
> > > entry for the enforced membership fields: as recommended by the 
> > > current manual. I must display the information entered on existing and 
> > > later pages. Within the primary database the items entered through 
> > > selected drop down lists appear as index which mean nothing to an end 
> > > user. I can retrieve the  indexed items by using something like in the 
> > > controller/function: 
> > 
> > > current_customer_name = 
> > > db(db.customer_names.id==names.index).select('name') 
> > 
> > The select returns a Rows object, not just one row and not a field of 
> > that row 
> > so to get to the name field value you can do 
> > 
> > db(db.customer_names.id==names.index).select('name').first().name 
> > 
> > or 
> > db(db.customer_names.id==names.index).select('name')[0].name 
> > 
> > and then your variable will contain only the customer's name. 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > > and is displayed in the view html with: 
> > 
> > > {{=current_customer_name)) 
> > 
> > > I need the results to be displayed in this form (which it does not): 
> > > The Big Company 
> > 
> > > It displays this (which won't work for 
> > > me):                                                 NAME 
> > 
> > > ------------------------------ 
> > 
> > > The Big Company 
> > 
> > > I would appreciate any advice or pointers on where to look further. 
> > > thanks in advance. 
> > 
> > > James C.

Reply via email to