perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Ludwig <>
Subject Acess current request using static method
Date Wed, 07 Jan 2009 17:40:16 GMT
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

View raw message