From modperl-return-58918-apmail-perl-modperl-archive=perl.apache.org@perl.apache.org Wed Jan 07 17:41:05 2009 Return-Path: Delivered-To: apmail-perl-modperl-archive@www.apache.org Received: (qmail 34297 invoked from network); 7 Jan 2009 17:41:05 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 7 Jan 2009 17:41:05 -0000 Received: (qmail 48269 invoked by uid 500); 7 Jan 2009 17:41:01 -0000 Delivered-To: apmail-perl-modperl-archive@perl.apache.org Received: (qmail 48251 invoked by uid 500); 7 Jan 2009 17:41:01 -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 48242 invoked by uid 99); 7 Jan 2009 17:41:01 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Jan 2009 09:41:01 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [80.237.204.15] (HELO lobster.as-guides.com) (80.237.204.15) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Jan 2009 17:40:53 +0000 Received: from seaweed.as-guides.com ([87.193.161.199] helo=[172.16.100.126]) by lobster.as-guides.com with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1LKcO8-0005oX-Du for modperl@perl.apache.org; Wed, 07 Jan 2009 18:40:30 +0100 Message-ID: <4964E900.2000704@as-guides.com> Date: Wed, 07 Jan 2009 18:40:16 +0100 From: Michael Ludwig User-Agent: Thunderbird 2.0.0.19 (Windows/20081209) MIME-Version: 1.0 To: modperl@perl.apache.org Subject: Acess current request using static method Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-SA-Do-Not-Run: Yes X-Spam-Score: -2.0 (--) X-Virus-Checked: Checked by ClamAV on apache.org In 2.0, is there a way to access the current request object using one of the classes in the following fashion? my $r = Apache2::RequestRec->current(); # INVALID! So you could access the request object from a function without passing the request in as a parameter. Background is, I want to access Apache functionality in a function that is called from XSL. Writing this, it occurred to me that it can be done as follows: use Apache2::Util; ... sub handler { ... my $strftime_1 = sub { Apache2::Util::ht_time( $r->pool, $_[0], '%Y-%m-%d %H:%M', 0); }; my $strftime_2 = sub { Apache2::Util::ht_time( $r->pool, $_[0], '%H:%M', 0); }; my $prsr = XML::LibXML->new; my $xsl = XML::LibXSLT->new; XML::LibXSLT->register_function('urn:perl', 'strftime-1', $strftime_1); XML::LibXSLT->register_function('urn:perl', 'strftime-2', $strftime_2); ... } This works. So I don't have to load the POSIX module to get strftime. Anyway, is there a way to do what I asked? Michael Ludwig