[albatross-users] User input sought
Dave Cole
djc at object-craft.com.au
Fri Dec 6 14:33:59 EST 2002
>>>>> "Andrew" == Andrew McNamara <andrewm at object-craft.com.au> writes:
>>> Another possible option is to have add_session_vars raise an
>>> exception if the variable doesn't already exist
>> The problem I've run into a few times is having multiple paths
>> into the current page, some of which set 'blah' into the session
>> (with an appropriate value), some of which don't.
>>
>> So I do something like: ctx.add_session_vars('blah') try:
>> ctx.locals.blah except AttributeError: ctx.locals.blah = 1 which is
>> ugly and long_winded.
Andrew> Yep - Dave and I have been considering this - I also find
Andrew> myself doing something like the above all the time. I guess a
Andrew> setdefault() method for ctx.locals has the virtue of mirroring
Andrew> the setdefault() method for mapping types. I'm not sure I like
Andrew> the idea of poluting the locals namespace, however.
Andrew> I guess my perfered option is a default_session_vars() method
Andrew> that both registers and, if not already set, sets session
Andrew> vars. Should it set one variable at a time, or should it take
Andrew> tuples as args? I think I'd prefer the former - less chance of
Andrew> mistakes.
Perhaps
ctx.default_session_var(name, value)
- Dave
--
http://www.object-craft.com.au
More information about the Albatross-users
mailing list