> "Ryan" == Ryan Tate <[EMAIL PROTECTED]> writes:
Ryan> Hello,
Ryan> I recently moved a simple CGI::Prototype-based Web app over to a
Ryan> mod_perl2 installation. It wasn't too hard.
That's good to hear. I tried to design CGIP with mod_perl in mind,
but I had no current customers using mod_perl directly.
Ryan> One thing I eventually noticed: if you dispatch to objects
Ryan> representing particular classes, as CGI::Prototype::Hidden does (see
Ryan> name_to_page and its call to $package->reflect->object), you have to
Ryan> be careful to re-initialize slots as needed, because package objects
Ryan> are not garbage collected and thus will persist.
Yes. And this can be trouble, as you've seen.
Ryan> To handle initialization, for each class with slots I want killed
Ryan> before the next request, I do a control_leave with
Ryan> $self->reflect->deleteSlots(qw(userfoo userbar tempfoo tempbar)),
Ryan> along with $self->SUPER::control_leave(@_) for any classes above.
That would seem to be the logical place to do this.
Another way would be to put all your slots into one big "per hit" slot,
and then ensure that this is cleared out:
sub My::App::control_enter {
my $self = shift;
$self->reflect->addSlot(per_hit => {});
}
Through testing, I see that addSlot also throws away any previous
meaning for the slot, so this trashes the previous round data just
fine.
Then in any thing that needed it:
sub randomfunc {
my $self = shift;
my $per_hit = $self->per_hit;
$per_hit->{foo} = "bar";
}
In this case, you just need to keep your keys of $per_hit clean,
but you had to do that with slots anyway. :) This'll also be faster
than adding and deleting slots every time.
Ryan> PS Liked the first Linux Mag article.
Parts two and three coming up... :)
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
---
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
___
cgi-prototype-users mailing list
cgi-prototype-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cgi-prototype-users