Return-Path: Delivered-To: apmail-perl-modperl-archive@www.apache.org Received: (qmail 96870 invoked from network); 24 Sep 2007 08:48:02 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 24 Sep 2007 08:48:02 -0000 Received: (qmail 51299 invoked by uid 500); 24 Sep 2007 08:47:47 -0000 Delivered-To: apmail-perl-modperl-archive@perl.apache.org Received: (qmail 51278 invoked by uid 500); 24 Sep 2007 08:47:47 -0000 Mailing-List: contact modperl-help@perl.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list modperl@perl.apache.org Received: (qmail 51267 invoked by uid 99); 24 Sep 2007 08:47:46 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Sep 2007 01:47:46 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of deepfryed@gmail.com designates 64.233.182.187 as permitted sender) Received: from [64.233.182.187] (HELO nf-out-0910.google.com) (64.233.182.187) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Sep 2007 08:47:46 +0000 Received: by nf-out-0910.google.com with SMTP id k4so1186879nfd for ; Mon, 24 Sep 2007 01:47:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; bh=PSP+CF1G7Y1zz16X7tFysUoPDyA1rsIfhjgpG/orBOc=; b=TvriZy0DvI8ZkYwuC0MaZNwWYBYkkqbT805pQuRHdrn95QVeuYdFwG8O4/FrQs6Zyp0Ks0/5GoIXx9TG3Sb/vkJUrBEB8XYBSr/JqJmE92mXil2Uqol8X9AMBejIydunFu/fs12zKalLIDkE6ARDvup8Yg+Wg8H69n5norP4EGE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=V+BLHTmqjrsxtRw71dyHK4xB045hbM2Sz78qx/ZzGmhCSDmalvK1MEZt8CyEMaDOmsEnN7WNoDK+50SmPIkcmULIttUngFj96asuFrmQ2dSWBhsTE80Pr8wYYWUPhJCEC6qg40knSFELa1SZgirDipWhJEYxjrDhPjBwzTo1NIQ= Received: by 10.78.129.16 with SMTP id b16mr1214716hud.1190623643366; Mon, 24 Sep 2007 01:47:23 -0700 (PDT) Received: by 10.78.174.19 with HTTP; Mon, 24 Sep 2007 01:47:23 -0700 (PDT) Message-ID: <70b2ff110709240147m19a2bf6fvcb5e9fc75077d724@mail.gmail.com> Date: Mon, 24 Sep 2007 18:47:23 +1000 From: "bharanee rathna" To: "jk jk" Subject: Re: Problem with RequestRec and Headers Cc: modperl@perl.apache.org In-Reply-To: <2913bcb80709232107l2eb0c09cr8a2c5470519c06aa@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_43278_3717833.1190623643351" References: <2913bcb80709211323w27416a06p3c9b0a0134aa1906@mail.gmail.com> <46F625D1.9040502@ectoplasm.org> <2913bcb80709230803u2fa9be0bn97c794ba9090425b@mail.gmail.com> <2913bcb80709231245t3cb6ed05l881a26bf3a85407b@mail.gmail.com> <70b2ff110709231957q43aad715oaadbe01a47d47976@mail.gmail.com> <2913bcb80709232107l2eb0c09cr8a2c5470519c06aa@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_43278_3717833.1190623643351 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Yep, that's a bug perldoc Apache2::RequestUtil # get the global request object (requires PerlOptions +GlobalRequest) $r = Apache2::RequestUtil->request; which means u need GlobalRequest in apache config, which I'm not a big fan of. Better raise a bug in cpan rt for this module and get Tatsuhiko to fix it. By the looks of it, this hasn't been updated in a while. personally I don't really see a need for Apache::Singleton::Process unless there needs to be a module for consistency in Apache:: namespace, class::singleton does pretty much the same job. If you need a per-request singleton meanwhile, cookup something quickly of your own that uses apache pnotes to store the instance perldoc Apache2::RequestRec On 9/24/07, jk jk wrote: > > I looked at the source. It does seem to be written for both. My > understanding was that everything for apache2 was supposed to be in the > Apach2:: namespace. In any case I posted the install error below. Does an > environment variable need to be set? > > > perl Makefile.PL > Warning: prerequisite mod_perl 0 not found. > Writing Makefile for Apache::Singleton > > If I install it anyway I get "[Sun Sep 23 15:09:49 2007] [error] Can't > locate Apache/RequestUtil.pm in @INC (@INC contains:......" > > Thanks. --JAK > > On 9/23/07, bharanee rathna wrote: > > > > AFAIK Apache::Singleton works for MP2, also it does both per request and > > per process singletons. > > > > > > On 9/24/07, jk jk < jk.lists.questions@gmail.com> wrote: > > > > > > I've been trying to use Apache::Singleton::Request under the > > > assumption that you're right about Class::Singleton being the crux of the > > > issue. Unfortunately, I can't get it working under Apache2. Is there a > > > different module for mp2/apache2 ? Thanks for your patience. --JAK > > > > > > On 9/23/07, jk jk wrote: > > > > > > > > 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/ > > > > > > > > > > > > > > > > > > > > > > > > > ------=_Part_43278_3717833.1190623643351 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Yep, that's a bug

perldoc Apache2::RequestUtil

  # get the global request object (requires PerlOptions +GlobalRequest)
  $r = Apache2::RequestUtil->request;

which means u need GlobalRequest in apache config, which I'm not a big fan of. Better raise a bug in cpan rt for this module and get Tatsuhiko to fix it. By the looks of it, this hasn't been updated in a while.

personally I don't really see a need for Apache::Singleton::Process unless there needs to be a module for consistency in Apache:: namespace, class::singleton does pretty much the same job. If you need a per-request singleton meanwhile,  cookup something quickly of your own that uses apache pnotes to store the instance

perldoc Apache2::RequestRec



On 9/24/07, jk jk <jk.lists.questions@gmail.com> wrote:
I looked at the source.  It does seem to be written for both.  My understanding was that everything for apache2 was supposed to be in the Apach2:: namespace.  In any case I posted the install error below.  Does an environment variable need to be set?


perl Makefile.PL
Warning: prerequisite mod_perl 0 not found.
Writing Makefile for Apache::Singleton

If I install it anyway I get "[Sun Sep 23 15:09:49 2007] [error] Can't locate Apache/RequestUtil.pm in @INC (@INC contains:......"

Thanks. --JAK


On 9/23/07, bharanee rathna < deepfryed@gmail.com> wrote:
AFAIK Apache::Singleton works for MP2, also it does both per request and per process singletons.



On 9/24/07, jk jk < jk.lists.questions@gmail.com> wrote:
I've been trying to use Apache::Singleton::Request under the assumption that you're right about Class::Singleton being the crux of the issue.  Unfortunately, I can't get it working under Apache2.  Is there a different module for mp2/apache2 ?  Thanks for your patience. --JAK

On 9/23/07, jk jk <jk.lists.questions@gmail.com > wrote:
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/







------=_Part_43278_3717833.1190623643351--