[albatross-users] User input sought

Gregory Bond gnb at itga.com.au
Fri Dec 6 12:57:41 EST 2002


> 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.

Perhaps we could have a version of add_session_vars to also set default value.
Perhaps something like
	ctx.add_session_vars_default('blah', 1)
or, more complex,
	ctx.add_session_vars_default(('blah', 'blah2'), [1, None])
or, to turn it inside out a bit,
	ctx.add_session_vars_default(('blah', 1), ('blah2', None))

Or we could add a setdefault member to the Vars type:
	ctx.add_session_vars('blah')
	ctx.locals.setdefault('blah', 1)






More information about the Albatross-users mailing list