perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kjetil Kjernsmo <kje...@kjernsmo.net>
Subject Re: Tied Apache::Session objects in AxKit::XSP::BasicSession
Date Fri, 17 Jun 2005 00:09:12 GMT
Hi and thanks for the response!

On onsdag 15 juni 2005, 10:06, Perrin Harkins wrote:
> Ideally, I would suggest you stop putting your session in a global.
> That's just asking for trouble.  

Yeah, I've had ambitions to do this for a long time, but not really a 
way to implement it gracefully. 

> If you put it in $r->pnotes() instead,

OK, I have been working a couple of nights now to do this, and have been 
making some progress. But I seem to have difficulties with actually 
passing the tied hash, that is, making sure I pass the actually tied 
object, not just the data hash. 

I currently assign to pnotes like this:
    $r->pnotes(session => tied %session);
and the Plugin is where this is most important. 

Since most "methods" access this in some way, I created a little helper 
sub in the XSP:
sub _session {
    my %session = @_;
    my $r = Apache->request;
    if (defined(%session)) { 
	$r->pnotes(session => tied %session);
	return undef;
    } else {
	return %{ $r->pnotes("session") };
    }
}

When I call this, I seem to be getting a big data structure, with the 
data, blessed references to the data storage object, etc. 

But it is apparently not the tied object nevertheless as I'm 
subsequently doing 
    tied(%session)->delete;
and that stops with an error "Can't call method "delete" on an undefined 
value"...

I have tried a few different things, like return tied 
%{ $r->pnotes("session") };
but as one can probably guess, I really don't understand this... 

The latest version is checked into SVN, and can be seen on the URI in my 
initial email.

> you will never have to worry about it persisting and you can 
> get rid of the cleanup handler.

Would be nice, but there is some code in it I would have to figure out 
how to handle, it would be nice to just drop it if I can. 

Cheers,

Kjetil
-- 
Kjetil Kjernsmo
Programmer/Astrophysicist/Skeptic/Ski-orienteer/Orienteer/Mountaineer
kjetil@kjernsmo.net  webmaster@skepsis.no  editor@learn-orienteering.org
Homepage: http://www.kjetil.kjernsmo.net/        OpenPGP KeyID: 6A6A0BBC

Mime
View raw message