On Friday, August 10, 2012 5:38:27 AM UTC-4, Annet wrote:
>
> When request.args(0) is 628
>
>
>> from gluon.storage import Storage
>> session[request.args(0)] = Storage(id=request.args(0))
>> # now it's a Storage object, so you can start adding new keys
>> session[request.args(0)].otherkey = "other value"
>>
>
> Is this equivalent to session6 = {'id':6} or 6={'id':6}
>
It's equivalent to session[6].id = 6 or session[6]['id'] = 6. You can't do
session.6 because Python identifiers can't start with a digit (if the node
ID started with a letter or underscore, then you could use that notation as
well).
> I am asking this because the following:
>
> from gluon.storage import Storage
>> session[request.args(0)] = Storage()
>> id = session[request.args(0)].id = request.args(0)
>>
>> Then everywhere you currently refer to session[request.args(0)].id, you
>> can simply use id (even without the above, you could just use
>> request.args(0) itself, since it is equivalent to
>> session[requests.args(0)].id).
>>
>
> .... isn't completely clear to me, when I have created Storage object for
> node with id 6, node with id 28 and node with id 34 and have set every
> objects key to the corresponding values, then what you're saying is that
> 6.menu renders node 6's menu and 28.menu renders node 28's menu?
>
It would be session[6].menu, session[28].menu, etc.
Anthony
--