On mandag 20 juni 2005, 20:26, Perrin Harkins wrote:
> > Uh, actually, that's what I did in my first version, as it is the
> > intuitive thing to do, and couldn't get it to do what it should...
> > To me, it looked as if just the hash was passed, not the tied
> > object... Of course, it could be that I did something else entirely
> > wrong....
>
> You just need to call tied() on the hash to get the object at any
> time.

Mmm, ok.


> > Since I was going to retrieve this session reference from pnotes
> > maaany times in the code, I created a little sub for it, perhaps
> > that wasn't such a good idea...? But I think it looked as if only
> > the hash was passed allready in there, so I don't think that was
> > the problem... No alarm bells are going off for me here, any for
> > you?
>
> I'm not sure what you're talking about here.  Show me the code you're
> referring to.

OK. The whole thing is checked in at 
http://svn.kjernsmo.net/AxKit-XSP-BasicSession/trunk/ and will reveal 
how confused I am... :-)

Briefly, I think the problem is buried somewhere in the invalidation 
code, lets see how it looks right now:
sub invalidate
{
    my $self = shift if (_calledAsMethod(@_));
    my $r = Apache->request;
#    my %session = _session;
    my %session = tied %{ $r->pnotes("session") };
    warn Dumper(\%session);
    warn ref tied %session;
    AxKit::Debug(9, "[BSession] Will attempt to invalidate session");
    tied(%session)->delete;
    untie %session;
    undef %session;
    #
    # Write it back to pnotes
    _session(%session);

    Apache::AxKit::Plugin::BasicSession::handler($r);
    return;
}

It never gets further than tied(%session)->delete; this is how the log 
looks:
Reference found where even-sized list expected 
at /usr/local/lib/site_perl/AxKit/XSP/BasicSession.pm line 247.
$VAR1 = {
          'Apache::Session::Flex=HASH(0x841a004)' => undef
        };
Warning: something's wrong 
at /usr/local/lib/site_perl/AxKit/XSP/BasicSession.pm line 249.
[Tue Jun 21 23:51:30 2005] [warn] [client 127.0.0.1] [AxKit] [BSession] 
Will attempt to invalidate session
[Tue Jun 21 23:51:30 2005] [warn] [client 127.0.0.1] [AxKit] Caught an 
exception
[Tue Jun 21 23:51:30 2005] [error] [client 127.0.0.1] [AxKit] [Error] 
Can't call method "delete" on an undefined value 
at /usr/local/lib/site_perl/AxKit/XSP/BasicSession.pm line 252.

So, at that point, %session isn't what I expect it to be....

The above is an attempt to bypass my little function _session, which I 
would use to get or set the session hash, since it is something I do a 
lot.

It looks like this:
sub _session {
    my %session = @_;
    my $r = Apache->request;
    if (defined(%session)) { 
        $r->pnotes(session => \%session);
        return undef;
    } else {
        return %{ $r->pnotes("session") };
    }
}

It is the last return that interests us now, and I've tried to do 
return tied %{ $r->pnotes("session") };

If I take the minimal route and return %{ $r->pnotes("session") }; from 
_session and just set my %session = _session;
then Dumper will give:
$VAR1 = {
          '_access_time' => 1119392841,
          '_session_id' => 'ba3e899edd0e06939a280fca93e3affc',
          '_creation_time' => 1119385419
        };

which is the correct data, but obviously not tied to anything, so      
tied(%session)->delete; fails.

So, this is basically why I tried 
    $r->pnotes(session => tied %session);
thinking it would help, but clearly not....

Was this sufficiently clear...?

Cheers,

Kjetil
-- 
Kjetil Kjernsmo
Programmer/Astrophysicist/Skeptic/Ski-orienteer/Orienteer/Mountaineer
[EMAIL PROTECTED]  [EMAIL PROTECTED]  [EMAIL PROTECTED]
Homepage: http://www.kjetil.kjernsmo.net/        OpenPGP KeyID: 6A6A0BBC

Reply via email to