perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "jk jk" <jk.lists.questi...@gmail.com>
Subject Re: Problem with RequestRec and Headers
Date Sun, 23 Sep 2007 15:03:53 GMT
Why is that?  Class::Singleton is modperl compatible, Apache::Singleton is
the same thing with a few more features.  Its purpose to simplify singleton
application creation.  My understanding was it would only allow a single
instance of the object to be created for each request, not forever.  Please
explain your reasoning.  Thanks. --JAK

On 9/23/07, Philippe M. Chiasson <gozer@ectoplasm.org> wrote:
>
> jk jk wrote:
> > I'm trying to port a preexisting CGI app to mod_perl2 and could use some
> > help.
> >
> > Here goes a test case that should illustrate my problem:
> >
> > The code pasted below loads the page properly the first time it's
> > accessed.  However, upon multiple reloads in firefox, the headers either
> > disappear altogether or the page is downloaded in the download manager.
> > I assume this is because the wrong $r object is being accessed by the
> > request?  In any case, I'm at a loss and would really appreciate some
> > input.  Thanks in advance.
> > [...]
> >
> > =============
> > File: testme/testmod.pm
> > =============
> >
> > package testme::testmod;
> >
> > use Apache2::RequestUtil;
> > use strict;
> >
> > use base qw /Class::Singleton/;
>
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> From the documentation of Class::Singleton:
>
> # this only gets called the first time instance() is called
>
> > sub _new_instance{
> >
> >     my ( $class, $r ) = @_;
> >
> >     my $self = {};
> >
> >     bless $self, $class;
> >
> >     $self->{r} = $r;
> >
> >     return ( $self );
> >
> > }
>
> So effectively, your code will capture the $r (once for each child)
> from the first request and keep it forever. Trying to use it for
> subsequent
> requests will cause the kind of problems you've seen.
>
> ------------------------------------------------------------------------
> Philippe M. Chiasson     GPG: F9BFE0C2480E7680 1AE53631CB32A107 88C3A5A5
> http://gozer.ectoplasm.org/       m/gozer\@(apache|cpan|ectoplasm)\.org/
>
>
>

Mime
View raw message