[albatross-users] Getting things *out* of session_vars?

Michael C. Neel neel at mediapulse.com
Thu Apr 24 01:48:50 EST 2003


You have to create the ctx.local.(var) for all vars you will be adding
to the session before you add them.  This was brought up on the list,
and some alternate methods to the system talked about, I don't know if
the next release made any changes though.

You should not have to call page_enter yourself.  Without seeing the
app, page objects, and the templates used it hard to say why you are
having to do that.  With a little more info, someone on the list might
be able to see exactly whats going wrong.

Mike

-----Original Message-----
From: VanL [mailto:vlindberg at verio.net] 
Sent: Tuesday, April 22, 2003 9:42 PM
To: Michael C. Neel
Cc: albatross-users at object-craft.com.au
Subject: Re: [albatross-users] Getting things *out* of session_vars?


Hello,

Michael C. Neel wrote:

>You need to add the following line to the second part:
>
>for v in all_vars:
>    setarrt(ctx.locals,v, None)
>    ctx.add_session_var(v)
>
I neglected to say this, but for most vars I *am* doing this on 
page_enter.  The problem occurs on the next page:

[Previous code here]
[Passes all validation checks]
[add session vars]
ctx.set_page('nextpage')

On the nextpage

def page_process(ctx):
    if not hasattr(ctx.locals, 'var_set_on_previous_page'):
        # Var set on previous page is not here.  Bounce back
        ctx.set_page('prevpage')

I keep on getting bounced back to prevpage, which makes me think that 
the session vars aren't in ctx.locals.  Hence my original question, how 
do I get stuff out of session_vars?

On a related note, I do have a page_enter function

def page_enter(ctx):
    # Initialization here
    if not hasattr(ctx.locals, somevar): setattr(ctx.locals, 'somevar',
'')

However, I have to call this function manually, in page_display:

def page_display(ctx):
    page_enter(ctx)
    [continue]
   
Is that right?  I got the impression that a function of that name would 
be called automagically.
I am using mod_python 2.78, albatross 1.01, python2.2, apache 1.3-recent

something.  This is a ModularSessionFileApp.


VanL






More information about the Albatross-users mailing list