[albatross-users] Wiki example and related extension: iterate over ctx/session
Gregory Bond
gnb at itga.com.au
Tue Jul 8 16:14:55 EST 2003
andrewm at object-craft.com.au said:
> I'm not really sure what people are getting at here
The sequence I was thinking of is this:
def page_enter(self, ctx):
ctx.locals.session = ctx.session_vars() # aka ctx.__vars.keys()
# ...
ctx.add_session_vars('new')
def page_display(self, ctx):
ctx.run_template('debug.ht')
where debug.ht does
Session Vars are:<ul>
<al-for iter="i" expr="session"><li><al-value expr="i.value()"/></li></
al-for>
</ul>
This will not show 'new' as a session variable, because it was added after the
session_vars() call. Putting (a reference to) the __vars dict into the
session will not have this problem.
The other way around the problem is to do the "ctx.locals.session =
ctx.session_vars()" bit in every page_display() routine just before the
run_template call, which is ugly and unnecessary boilerplate.
Does that make it clearer?
More information about the Albatross-users
mailing list