No, it doesn't work. The results of the select (with cacheable=True) is a
Rows object:
Person.id,Person.First_name,Person.Last_name,Person.Address1,Person.Address2,Per
son.City,Person.State,Person.Zip,Session.Start_datetime,Session.End_datetime
32,Sue,Clavin,1720 Wood Ave.,,Colorado Springs,CO,80907,2013-01-18
18:00:00,2013
-01-18 20:00:00
38,Julie,O'Neill,1052 Walters Point,,Monument,CO,80132,2013-01-18
18:00:00,2013-
01-18 20:00:00
I store that into a session variable (session.currAssgmts = currAssgmts),
and then also use the object (currAssgmts, NOT session.currAssgmts) for my
processing. The second time through I notice that it's in a session
variable, so I pull it out (currAssgmts = session.currAssgmts), but now
it's a list of Row objects:
[<Row {'Person': {'City': 'Colorado Springs', 'First_name': 'Sue',
'Last_name':
'Clavin', 'Zip': '80907', 'Address1': '1720 Wood Ave.', 'Address2': '',
'State':
'CO', 'id': 32}, 'Session': {'Start_datetime': datetime.datetime(2013, 1,
18, 1
8, 0), 'End_datetime': datetime.datetime(2013, 1, 18, 20, 0)}}>, <Row
{'Person':
{'City': 'Monument', 'First_name': 'Julie', 'Last_name': "O'Neill", 'Zip':
'801
32', 'Address1': '1052 Walters Point', 'Address2': '', 'State': 'CO', 'id':
38},
'Session': {'Start_datetime': datetime.datetime(2013, 1, 18, 18, 0),
'End_datet
ime': datetime.datetime(2013, 1, 18, 20, 0)}}>]
When I try to reference it thusly:
startDatetime = currAssgmts[0].Session.Start_datetime
I get:
<type 'exceptions.AttributeError'> 'dict' object has no attribute
'Start_datetime'
I don't get that error when I work on the results of the select; everything
works. It's only when I pull the stored Rows back out of the session
variable.
On Thursday, September 27, 2012 8:41:44 PM UTC-6, Massimo Di Pierro wrote:
>
> While we can do this. I think you try d
>
> rows = db().select(cacheable=True)
>
> rows will lack update_record and delete_record methods but they should be
> pickable. Let is know if that works.
>
> On Thursday, 27 September 2012 21:26:32 UTC-5, MichaelF wrote:
>>
>> I want to store Rows values in a session variable. I realize I can't
>> store the Rows object directly, so I use rows.to_list(). The problem is
>> that where I used to be able to use attributes on the Rows object (e.g.,
>> rows[0].Meet.Name), now I would have to use string keys when I access the
>> list of dicts:
>>
>> rows = db...select()
>> if rows[0].Meet.Name == ...
>> session.rowsList = rows.to_list()
>> ...
>> rows = session.rowsList
>> if rows[0]['Meet']['Name'] == ...
>>
>> Is there a simple way to convert the Rows object (or the result of the
>> to_list() call) to a list of Storage objects?
>>
>> Realize that each Row (and each dict object in the to_list()) can have at
>> least ("at most," maybe) two levels of dicts. The select might have
>> selected from several tables. For example, a simplified result of a select
>> from two joined tables (Rows.to_list(), returning two rows):
>>
>> [{'Person': {'City': 'Springs', 'First_name': 'Sue'},
>> 'Meet': {'Start_datetime': datetime.datetime(2013, 1, 18, 18, 0)}},
>> {'Person': {'City': '...}}]
>>
>> Yes, I can write the code; but does the code already exist...say
>> Rows.to_storage()?
>>
>> Thanks.
>>
>
--