hi all...
over the past few months several people have asked about a port of
Apache::Template for mod_perl 2.0 - mostly on the mod_perl list, but a few
cornered me at ApacheCon as well. I told each of them that even though
Apache::compat was going to be no help for this particular module (since it
uses directive handlers) the port shouldn't be so bad. it turns out it
wasn't all that difficult.
a patch against the current version (0.08) is attached, but I've put a
complete tarball here as well:
http://www.modperlcookbook.org/~geoff/modules/experimental/Apache-Template-2.00_01.tar.gz
keep in mind that all I did was minimally alter the code to allow it to run
under mod_perl 2.0. specifically, since I'm not an Apache::Template user, I
did very little in the way of checking whether functionality was maintained.
so, no warranty, etc.
I did, however, add a few Apache-Test based tests to make sure that it was
minimally working - if these were added to and expanded within the current
mp1 Apache::Template by actual users it would be much easier to verify mp2
functionality.
anyway, for what it's worth. enjoy.
--Geoff
diff -ruN Changes Changes
--- Changes 2003-08-21 10:21:09.000000000 -0400
+++ Changes 2003-12-03 13:41:18.000000000 -0500
@@ -14,6 +14,12 @@
#========================================================================
#------------------------------------------------------------------------
+# Version 2.00_01 -
+#------------------------------------------------------------------------
+
+* Preliminary port to mod_perl 2.0 by Geoffrey Young
+
+#------------------------------------------------------------------------
# Version 0.08 - 21st August 2003
#------------------------------------------------------------------------
diff -ruN lib/Apache/Template.pm lib/Apache/Template.pm
--- lib/Apache/Template.pm 2003-08-21 10:20:17.000000000 -0400
+++ lib/Apache/Template.pm 2003-12-03 14:36:05.000000000 -0500
@@ -25,23 +25,202 @@
use strict;
use vars qw( $VERSION $DEBUG $ERROR $SERVICE );
-use DynaLoader ();
-use Apache::ModuleConfig ();
-use Apache::Constants qw( :common );
+use mod_perl 1.99_11; # sanity check for a recent version
+
+use Apache::RequestRec ();
+use Apache::Module ();
+use Apache::Log ();
+use Apache::RequestIO ();
+use Apache::Const -compile => qw(OK SERVER_ERROR TAKE1 TAKE12 FLAG
+ ITERATE TAKE2 RSRC_CONF ACCESS_CONF);
+
use Template::Service::Apache;
use Template::Config;
-$VERSION = '0.08';
+$VERSION = '2.00_01';
$ERROR = '';
$DEBUG = 0 unless defined $DEBUG;
$Template::Config::SERVICE = 'Template::Service::Apache';
-if ($ENV{ MOD_PERL }) {
- no strict;
- @ISA = qw( DynaLoader );
- __PACKAGE__->bootstrap($VERSION);
-}
-
+our @APACHE_MODULE_COMMANDS = (
+ #-- parsing/style options --
+ { name => 'TT2Tags',
+ errmsg => 'tag style or start and end tags for template directives',
+ args_how => Apache::TAKE12,
+ req_override => Apache::RSRC_CONF | Apache::ACCESS_CONF,
+ },
+ { name => 'TT2PreChomp',
+ errmsg => 'flag to remove newline and whitespace before directives',
+ args_how => Apache::FLAG,
+ req_override => Apache::RSRC_CONF | Apache::ACCESS_CONF,
+ },
+ { name => 'TT2PostChomp',
+ errmsg => 'flag to remove newline and whitespace after directives',
+ args_how => Apache::FLAG,
+ req_override => Apache::RSRC_CONF | Apache::ACCESS_CONF,
+ },
+ { name => 'TT2Trim',
+ errmsg => 'flag to trim whitespace surrounding template output',
+ args_how => Apache::FLAG,
+ req_override => Apache::RSRC_CONF | Apache::ACCESS_CONF,
+ },
+ { name => 'TT2AnyCase',
+ errmsg => 'flag to allow directive keywords in any case',
+ args_how => Apache::FLAG,
+ req_override => Apache::RSRC_CONF | Apache::ACCESS_CONF,
+ },
+ { name => 'TT2Interpolate',
+ errmsg => 'flag to interpolate embedded variable references',
+ args_how => Apache::FLAG,
+ req_override => Apache::RSRC_CONF | Apache::ACCESS_CONF,
+ },
+
+ #-- file/directory options --
+ { name => 'TT2IncludePath',
+ errmsg => 'local path(s) containing templates',
+ args_how => Apache::ITERATE,
+ req_override => Apache::RSRC_CONF | Apache::ACCESS_CONF,
+ },
+ { name => 'TT2Absolute',
+ errmsg => 'flag to enable absolute filenames',
+ args_how => Apache::FLAG,
+ req_override => Apache::RSRC_CONF | Apache::ACCESS_CONF,
+ },
+ { name => 'TT2Relative',
+ errmsg => 'flag to enable relative filenames',
+ args_how => Apache::FLAG,
+ req_override => Apache::RSRC_CONF | Apache::ACCESS_CONF,
+ },
+ { name => 'TT2Delimiter',
+ errmsg => 'alternative directory delimiter',
+ args_how => Apache::TAKE1,
+ req_override => Apache::RSRC_CONF | Apache::ACCESS_CONF,
+ },
+
+ #-- service template options --
+ { name => 'TT2PreProcess',
+ errmsg => 'template(s) to process before each main template',
+ args_how => Apache::ITERATE,
+ req_override => Apache::RSRC_CONF | Apache::ACCESS_CONF,
+ },
+ { name => 'TT2PostProcess',
+ errmsg => 'template(s) to process after each main template',
+ args_how => Apache::ITERATE,
+ req_override => Apache::RSRC_CONF | Apache::ACCESS_CONF,
+ },
+ { name => 'TT2Process',
+ errmsg => 'template(s) to process instead of each main template',
+ args_how => Apache::ITERATE,
+ req_override => Apache::RSRC_CONF | Apache::ACCESS_CONF,
+ },
+ { name => 'TT2Wrapper',
+ errmsg => 'template(s) to wrap around each main template',
+ args_how => Apache::ITERATE,
+ req_override => Apache::RSRC_CONF | Apache::ACCESS_CONF,
+ },
+ { name => 'TT2Default',
+ errmsg => 'default template to process when another template is not
found',
+ args_how => Apache::TAKE1,
+ req_override => Apache::RSRC_CONF | Apache::ACCESS_CONF,
+ },
+ { name => 'TT2Error',
+ errmsg => 'template to process when an uncaught error occurs',
+ args_how => Apache::TAKE1,
+ req_override => Apache::RSRC_CONF | Apache::ACCESS_CONF,
+ },
+ { name => 'TT2Tolerant',
+ errmsg => 'flag to set error tolerance for providers',
+ args_how => Apache::FLAG,
+ req_override => Apache::RSRC_CONF | Apache::ACCESS_CONF,
+ },
+
+ #-- variable options --
+ { name => 'TT2Variable',
+ errmsg => 'define a template variable',
+ args_how => Apache::TAKE2,
+ req_override => Apache::RSRC_CONF | Apache::ACCESS_CONF,
+ },
+ { name => 'TT2Constant',
+ errmsg => 'define a constant variable',
+ args_how => Apache::TAKE2,
+ req_override => Apache::RSRC_CONF | Apache::ACCESS_CONF,
+ },
+ { name => 'TT2ConstantsNamespace',
+ errmsg => 'define variable namespace for constants',
+ args_how => Apache::TAKE1,
+ req_override => Apache::RSRC_CONF | Apache::ACCESS_CONF,
+ },
+
+ #-- runtime template processing options --
+ { name => 'TT2EvalPerl',
+ errmsg => 'flag to allow PERL blocks to be evaluated',
+ args_how => Apache::FLAG,
+ req_override => Apache::RSRC_CONF | Apache::ACCESS_CONF,
+ },
+ { name => 'TT2LoadPerl',
+ errmsg => 'flag to allow regular Perl modules to be loaded as plugins',
+ args_how => Apache::FLAG,
+ req_override => Apache::RSRC_CONF | Apache::ACCESS_CONF,
+ },
+ { name => 'TT2Recursion',
+ errmsg => 'flag to enable recursion into templates',
+ args_how => Apache::FLAG,
+ req_override => Apache::RSRC_CONF | Apache::ACCESS_CONF,
+ },
+
+ #-- plugin and filter options --
+ { name => 'TT2PluginBase',
+ errmsg => 'packages in which to locate for plugins',
+ args_how => Apache::ITERATE,
+ req_override => Apache::RSRC_CONF | Apache::ACCESS_CONF,
+ },
+
+ #-- caching options --
+ { name => 'TT2AutoReset',
+ errmsg => 'flag to reset (clear) any BLOCK definitions before
processing',
+ args_how => Apache::TAKE1,
+ req_override => Apache::RSRC_CONF | Apache::ACCESS_CONF,
+ },
+ { name => 'TT2CacheSize',
+ errmsg => 'integer limit to the number of compiled templates to cache
in memory',
+ args_how => Apache::TAKE1,
+ req_override => Apache::RSRC_CONF | Apache::ACCESS_CONF,
+ },
+ { name => 'TT2CompileExt',
+ errmsg => 'filename extension for caching compiled templates back to
disk',
+ args_how => Apache::TAKE1,
+ req_override => Apache::RSRC_CONF | Apache::ACCESS_CONF,
+ },
+ { name => 'TT2CompileDir',
+ errmsg => 'path to directory for caching compiled templates back to
disk',
+ args_how => Apache::TAKE1,
+ req_override => Apache::RSRC_CONF | Apache::ACCESS_CONF,
+ },
+
+ #-- misc options --
+ { name => 'TT2Debug',
+ errmsg => 'flag to enable debugging',
+ args_how => Apache::FLAG,
+ req_override => Apache::RSRC_CONF | Apache::ACCESS_CONF,
+ },
+
+ # -- service options --
+ { name => 'TT2Headers',
+ errmsg => 'list of keywords indicating HTTP headers to add',
+ args_how => Apache::ITERATE,
+ req_override => Apache::RSRC_CONF | Apache::ACCESS_CONF,
+ },
+ { name => 'TT2Params',
+ errmsg => 'list of keywords indicating parameters to add as template
variables',
+ args_how => Apache::ITERATE,
+ req_override => Apache::RSRC_CONF | Apache::ACCESS_CONF,
+ },
+ { name => 'TT2ServiceModule',
+ errmsg => 'name of class which implements template service module',
+ args_how => Apache::TAKE1,
+ req_override => Apache::RSRC_CONF | Apache::ACCESS_CONF,
+ },
+);
#------------------------------------------------------------------------
# handler($request)
@@ -66,12 +245,14 @@
# create and cache a service for each hostname
my $service = $SERVICE->{ $r->hostname() } ||= do {
- my $cfg = Apache::ModuleConfig->get($r) || { };
-# warn "setup service for hostname: ", $r->hostname, " ($cfg):\n",
-# dump_hash($cfg), "\n";
+ my $cfg = Apache::Module->get_config(__PACKAGE__,
+ $r->server,
+ $r->per_dir_config) || { };
+ warn "setup service for hostname: ", $r->hostname, " ($cfg):\n",
+ dump_hash($cfg), "\n" if $DEBUG;
Template::Config->service($cfg) || do {
- $r->log_reason(Template::Config->error(), $r->filename());
- return SERVER_ERROR;
+ $r->log_error(Template::Config->error(), ' ', $r->filename());
+ return Apache::SERVER_ERROR;
};
};
@@ -83,15 +264,15 @@
my $content = $service->process($template, $params);
unless (defined $content) {
- $r->log_reason($service->error(), $r->filename());
- return SERVER_ERROR;
+ $r->log_error($service->error(), ' ', $r->filename());
+ return Apache::SERVER_ERROR;
}
$service->headers($r, $template, \$content);
$r->print($content);
- return OK;
+ return Apache::OK;
}
@@ -1112,7 +1292,7 @@
=head1 VERSION
-This is version 0.08 of the Apache::Template module.
+This is version 2.00_01 of the Apache::Template module.
=head1 COPYRIGHT
diff -ruN lib/Template/Service/Apache.pm lib/Template/Service/Apache.pm
--- lib/Template/Service/Apache.pm 2003-08-21 05:46:45.000000000 -0400
+++ lib/Template/Service/Apache.pm 2003-12-03 13:19:50.000000000 -0500
@@ -38,9 +38,11 @@
$VERSION = sprintf("%d.%02d", q$Revision: 1.3 $ =~ /(\d+)\.(\d+)/);
$DEBUG = 0 unless defined $DEBUG;
-use Apache::Util qw( escape_uri ht_time );
-use Apache::Constants qw( :common );
-use Apache::Request;
+use Apache::Util qw( escape_path format_time );
+use Apache::Const -compile => qw( DECLINED SERVER_ERROR);
+use Apache::Log ();
+use Apache::RequestRec ();
+use Apache::Request 2.02;
#========================================================================
# ----- PUBLIC METHODS -----
@@ -59,12 +61,12 @@
my ($self, $r) = @_;
my $filename = $r->filename();
- return DECLINED unless -f $filename;
+ return Apache::DECLINED unless -f $filename;
$self->{ TEMPLATE_ERROR } = undef;
my ($template, $error) = $self->{ ROOT_PROVIDER }->fetch($filename);
if ($error && $error == &Template::Constants::STATUS_DECLINED) {
- return DECLINED;
+ return Apache::DECLINED;
}
elsif ($error) {
# save error as exception for params() to add to template vars
@@ -81,13 +83,13 @@
if ($template = $self->{ ERROR }) {
eval { $template = $self->{ CONTEXT }->template($template) };
if ($@) {
- $r->log_reason($self->{ TEMPLATE_ERROR } . " / $@", $filename);
- return SERVER_ERROR;
+ $r->log_error($self->{ TEMPLATE_ERROR } . " / $@", ' ', $filename);
+ return Apache::SERVER_ERROR;
}
}
else {
- $r->log_reason($template, $filename);
- return SERVER_ERROR;
+ $r->log_error($template, ' ', $filename);
+ return Apache::SERVER_ERROR;
}
}
@@ -133,7 +135,7 @@
}
$params->{ cookies } = {
- map { $1 => escape_uri($2) if (/([^=]+)=(.*)/) }
+ map { $1 => escape_path($2, $request->pool) if (/([^=]+)=(.*)/) }
grep(!/^$/, split(/;\s*/, $request->header_in('cookie'))),
} if $all or $plist->{ cookies };
@@ -156,13 +158,19 @@
my $all = $headers->{ all };
$r->content_type('text/html');
- $r->headers_out->add('Last-Modified' => ht_time($template->modtime()))
- if $all or $headers->{ modified } and $template;
$r->headers_out->add('Content-Length' => length $$content)
if $all or $headers->{ length };
$r->headers_out->add('E-tag' => sprintf q{"%s"}, md5_hex($$content))
if $all or $headers->{ etag };
- $r->send_http_header;
+
+ if ($all or $headers->{ modified } and $template) {
+ my $fmt = '%a, %d %b %Y %H:%M:%S %Z';
+
+ my $ht_time = Apache::Util::format_time($template->modtime(),
+ $fmt, 1, $r->pool);
+
+ $r->headers_out->add('Last-Modified' => $ht_time)
+ }
}
diff -ruN Makefile.PL Makefile.PL
--- Makefile.PL 2003-08-21 09:21:52.000000000 -0400
+++ Makefile.PL 2003-12-03 11:35:41.000000000 -0500
@@ -1,205 +1,24 @@
-package Apache::Template;
+#!perl
-use ExtUtils::MakeMaker;
-use lib qw( lib );
-use Apache::Template;
-use Apache::ExtUtils qw( command_table );
-use Apache::src ();
+use 5.008;
+use Apache2 ();
+use ModPerl::MM ();
+use Apache::Test;
+use Apache::TestMM qw(test clean);
+use Apache::TestRunPerl ();
+Apache::TestMM::filter_args();
+Apache::TestRunPerl->generate_script();
-my @directives = (
- #-- parsing/style options --
- { name => 'TT2Tags',
- errmsg => 'tag style or start and end tags for template directives',
- args_how => 'TAKE12',
- req_override => 'RSRC_CONF | ACCESS_CONF',
- },
- { name => 'TT2PreChomp',
- errmsg => 'flag to remove newline and whitespace before directives',
- args_how => 'FLAG',
- req_override => 'RSRC_CONF | ACCESS_CONF',
- },
- { name => 'TT2PostChomp',
- errmsg => 'flag to remove newline and whitespace after directives',
- args_how => 'FLAG',
- req_override => 'RSRC_CONF | ACCESS_CONF',
- },
- { name => 'TT2Trim',
- errmsg => 'flag to trim whitespace surrounding template output',
- args_how => 'FLAG',
- req_override => 'RSRC_CONF | ACCESS_CONF',
- },
- { name => 'TT2AnyCase',
- errmsg => 'flag to allow directive keywords in any case',
- args_how => 'FLAG',
- req_override => 'RSRC_CONF | ACCESS_CONF',
- },
- { name => 'TT2Interpolate',
- errmsg => 'flag to interpolate embedded variable references',
- args_how => 'FLAG',
- req_override => 'RSRC_CONF | ACCESS_CONF',
- },
-
- #-- file/directory options --
- { name => 'TT2IncludePath',
- errmsg => 'local path(s) containing templates',
- args_how => 'ITERATE',
- req_override => 'RSRC_CONF | ACCESS_CONF',
- },
- { name => 'TT2Absolute',
- errmsg => 'flag to enable absolute filenames',
- args_how => 'FLAG',
- req_override => 'RSRC_CONF | ACCESS_CONF',
- },
- { name => 'TT2Relative',
- errmsg => 'flag to enable relative filenames',
- args_how => 'FLAG',
- req_override => 'RSRC_CONF | ACCESS_CONF',
- },
- { name => 'TT2Delimiter',
- errmsg => 'alternative directory delimiter',
- args_how => 'TAKE1',
- req_override => 'RSRC_CONF | ACCESS_CONF',
- },
-
- #-- service template options --
- { name => 'TT2PreProcess',
- errmsg => 'template(s) to process before each main template',
- args_how => 'ITERATE',
- req_override => 'RSRC_CONF | ACCESS_CONF',
- },
- { name => 'TT2PostProcess',
- errmsg => 'template(s) to process after each main template',
- args_how => 'ITERATE',
- req_override => 'RSRC_CONF | ACCESS_CONF',
- },
- { name => 'TT2Process',
- errmsg => 'template(s) to process instead of each main template',
- args_how => 'ITERATE',
- req_override => 'RSRC_CONF | ACCESS_CONF',
- },
- { name => 'TT2Wrapper',
- errmsg => 'template(s) to wrap around each main template',
- args_how => 'ITERATE',
- req_override => 'RSRC_CONF | ACCESS_CONF',
- },
- { name => 'TT2Default',
- errmsg => 'default template to process when another template is not
found',
- args_how => 'TAKE1',
- req_override => 'RSRC_CONF | ACCESS_CONF',
- },
- { name => 'TT2Error',
- errmsg => 'template to process when an uncaught error occurs',
- args_how => 'TAKE1',
- req_override => 'RSRC_CONF | ACCESS_CONF',
- },
- { name => 'TT2Tolerant',
- errmsg => 'flag to set error tolerance for providers',
- args_how => 'FLAG',
- req_override => 'RSRC_CONF | ACCESS_CONF',
- },
-
- #-- variable options --
- { name => 'TT2Variable',
- errmsg => 'define a template variable',
- args_how => 'TAKE2',
- req_override => 'RSRC_CONF | ACCESS_CONF',
- },
- { name => 'TT2Constant',
- errmsg => 'define a constant variable',
- args_how => 'TAKE2',
- req_override => 'RSRC_CONF | ACCESS_CONF',
- },
- { name => 'TT2ConstantsNamespace',
- errmsg => 'define variable namespace for constants',
- args_how => 'TAKE1',
- req_override => 'RSRC_CONF | ACCESS_CONF',
- },
-
- #-- runtime template processing options --
- { name => 'TT2EvalPerl',
- errmsg => 'flag to allow PERL blocks to be evaluated',
- args_how => 'FLAG',
- req_override => 'RSRC_CONF | ACCESS_CONF',
- },
- { name => 'TT2LoadPerl',
- errmsg => 'flag to allow regular Perl modules to be loaded as plugins',
- args_how => 'FLAG',
- req_override => 'RSRC_CONF | ACCESS_CONF',
- },
- { name => 'TT2Recursion',
- errmsg => 'flag to enable recursion into templates',
- args_how => 'FLAG',
- req_override => 'RSRC_CONF | ACCESS_CONF',
- },
-
- #-- plugin and filter options --
- { name => 'TT2PluginBase',
- errmsg => 'packages in which to locate for plugins',
- args_how => 'ITERATE',
- req_override => 'RSRC_CONF | ACCESS_CONF',
- },
-
- #-- caching options --
- { name => 'TT2AutoReset',
- errmsg => 'flag to reset (clear) any BLOCK definitions before
processing',
- args_how => 'TAKE1',
- req_override => 'RSRC_CONF | ACCESS_CONF',
- },
- { name => 'TT2CacheSize',
- errmsg => 'integer limit to the number of compiled templates to cache
in memory',
- args_how => 'TAKE1',
- req_override => 'RSRC_CONF | ACCESS_CONF',
- },
- { name => 'TT2CompileExt',
- errmsg => 'filename extension for caching compiled templates back to
disk',
- args_how => 'TAKE1',
- req_override => 'RSRC_CONF | ACCESS_CONF',
- },
- { name => 'TT2CompileDir',
- errmsg => 'path to directory for caching compiled templates back to
disk',
- args_how => 'TAKE1',
- req_override => 'RSRC_CONF | ACCESS_CONF',
- },
-
- #-- misc options --
- { name => 'TT2Debug',
- errmsg => 'flag to enable debugging',
- args_how => 'FLAG',
- req_override => 'RSRC_CONF | ACCESS_CONF',
- },
-
- # -- service options --
- { name => 'TT2Headers',
- errmsg => 'list of keywords indicating HTTP headers to add',
- args_how => 'ITERATE',
- req_override => 'RSRC_CONF | ACCESS_CONF',
- },
- { name => 'TT2Params',
- errmsg => 'list of keywords indicating parameters to add as template
variables',
- args_how => 'ITERATE',
- req_override => 'RSRC_CONF | ACCESS_CONF',
- },
- { name => 'TT2ServiceModule',
- errmsg => 'name of class which implements template service module',
- args_how => 'TAKE1',
- req_override => 'RSRC_CONF | ACCESS_CONF',
- },
-);
-
-command_table([EMAIL PROTECTED]);
-
-WriteMakefile(
+ModPerl::MM::WriteMakefile(
'NAME' => 'Apache::Template',
'VERSION_FROM' => 'lib/Apache/Template.pm',
'PMLIBDIRS' => [ 'lib' ],
- 'INC' => Apache::src->new->inc,
- 'PREREQ_PM' => {
+ 'PREREQ_PM' => {
Template => 2.10,
Digest::MD5 => 2.09,
- Apache::Request => 0,
- Apache::ModuleConfig => 0
+ Apache::Request => 2.02,
+ mod_perl => 1.99_11,
},
);
-
diff -ruN MANIFEST MANIFEST
--- MANIFEST 2001-06-12 13:38:23.000000000 -0400
+++ MANIFEST 2003-12-03 14:36:12.000000000 -0500
@@ -1,8 +1,9 @@
Changes
+lib/Apache/Template.pm
+lib/Template/Service/Apache.pm
Makefile.PL
MANIFEST
README
-Template.xs
-test.pl
-lib/Apache/Template.pm
-lib/Template/Service/Apache.pm
+t/01include.t
+t/02perl.t
+t/conf/extra.last.conf.in
diff -ruN README README
--- README 2003-08-21 10:25:29.000000000 -0400
+++ README 2003-12-03 13:42:36.000000000 -0500
@@ -541,7 +541,7 @@
integration into the Apache::Template module.
VERSION
- This is version 0.08 of the Apache::Template module.
+ This is version 2.00_01 of the Apache::Template module.
COPYRIGHT
Copyright (C) 1996-2003 Andy Wardley. All Rights Reserved.
diff -ruN t/01include.t t/01include.t
--- t/01include.t 1969-12-31 19:00:00.000000000 -0500
+++ t/01include.t 2003-12-03 13:06:11.000000000 -0500
@@ -0,0 +1,30 @@
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test;
+use Apache::TestRequest;
+use Apache::TestUtil qw(t_cmp t_write_file);
+use Apache::Const -compile => qw(HTTP_OK);
+
+use File::Spec::Functions qw(catfile);
+
+plan tests => 2, have_module('mod_perl.c', 'mod_apreq');
+
+t_write_file(catfile(qw(htdocs include.txt)), <DATA>);
+t_write_file(catfile(qw(templates plain)), <DATA>);
+
+my $url = '/tt2/include.txt';
+
+my $response = GET $url;
+ok t_cmp(Apache::HTTP_OK, $response->code, "$url status");
+
+chomp(my $received = $response->content);
+chomp(my $expected = <<EOF);
+plain
+EOF
+
+ok t_cmp($expected, $received, "$url content");
+
+__END__
+[% INSERT plain %]
+plain
diff -ruN t/02perl.t t/02perl.t
--- t/02perl.t 1969-12-31 19:00:00.000000000 -0500
+++ t/02perl.t 2003-12-03 12:27:44.000000000 -0500
@@ -0,0 +1,28 @@
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test;
+use Apache::TestRequest;
+use Apache::TestUtil qw(t_cmp t_write_file);
+use Apache::Const -compile => qw(HTTP_OK);
+
+use File::Spec::Functions qw(catfile);
+
+plan tests => 2, have_module('mod_perl.c', 'mod_apreq');
+
+t_write_file(catfile(qw(htdocs perl.txt)), <DATA>);
+
+my $url = '/tt2/perl.txt';
+
+my $response = GET $url;
+ok t_cmp(Apache::HTTP_OK, $response->code, "$url status");
+
+chomp(my $received = $response->content);
+chomp(my $expected = <<EOF);
+perl
+EOF
+
+ok t_cmp($expected, $received, "$url content");
+
+__END__
+[% PERL %] print 'perl'; [% END %]
diff -ruN t/conf/extra.last.conf.in t/conf/extra.last.conf.in
--- t/conf/extra.last.conf.in 1969-12-31 19:00:00.000000000 -0500
+++ t/conf/extra.last.conf.in 2003-12-03 13:34:40.000000000 -0500
@@ -0,0 +1,18 @@
+<IfModule mod_perl.c>
+ <IfModule mod_apreq.c>
+
+ PerlLoadModule Apache::Template
+
+ TT2Trim On
+ TT2EvalPerl On
+ TT2IncludePath @ServerRoot@/templates
+ TT2Debug On
+
+ Alias /tt2 @DocumentRoot@
+ <Location /tt2>
+ SetHandler perl-script
+ PerlResponseHandler Apache::Template
+ </Location>
+
+ </IfModule>
+</IfModule>
Only in t/logs: cgisock
diff -ruN t/TEST t/TEST
--- t/TEST 1969-12-31 19:00:00.000000000 -0500
+++ t/TEST 2003-12-03 13:42:04.000000000 -0500
@@ -0,0 +1,18 @@
+#!/perl/perl-5.8.2/bin/perl
+# WARNING: this file is generated, do not edit
+# 01:
/perl/perl-5.8.2/lib/site_perl/5.8.2/i686-linux-thread-multi/Apache/TestConfig.pm:746
+# 02:
/perl/perl-5.8.2/lib/site_perl/5.8.2/i686-linux-thread-multi/Apache/TestConfig.pm:831
+# 03:
/perl/perl-5.8.2/lib/site_perl/5.8.2/i686-linux-thread-multi/Apache/TestRun.pm:1018
+# 04: Makefile.PL:11
+
+BEGIN { eval { require blib; } }
+use Apache2;
+
+use strict;
+use warnings FATAL => 'all';
+
+use lib qw(
+);
+
+
+use Apache::TestRunPerl ();Apache::TestRunPerl->new->run(@ARGV);
\ No newline at end of file
diff -ruN Template.xs Template.xs
--- Template.xs 2003-08-21 10:25:40.000000000 -0400
+++ Template.xs 1969-12-31 19:00:00.000000000 -0500
@@ -1,319 +0,0 @@
-#include "modules/perl/mod_perl.h"
-
-static mod_perl_perl_dir_config *newPerlConfig(pool *p)
-{
- mod_perl_perl_dir_config *cld =
- (mod_perl_perl_dir_config *)
- palloc(p, sizeof (mod_perl_perl_dir_config));
- cld->obj = Nullsv;
- cld->pclass = "Apache::Template";
- register_cleanup(p, cld, perl_perl_cmd_cleanup, null_cleanup);
- return cld;
-}
-
-static void *create_dir_config_sv (pool *p, char *dirname)
-{
- return newPerlConfig(p);
-}
-
-static void *create_srv_config_sv (pool *p, server_rec *s)
-{
- return newPerlConfig(p);
-}
-
-static void stash_mod_pointer (char *class, void *ptr)
-{
- SV *sv = newSV(0);
- sv_setref_pv(sv, NULL, (void*)ptr);
- hv_store(perl_get_hv("Apache::XS_ModuleConfig",TRUE),
- class, strlen(class), sv, FALSE);
-}
-
-static mod_perl_cmd_info cmd_info_TT2Tags = {
-"Apache::Template::TT2Tags", "",
-};
-static mod_perl_cmd_info cmd_info_TT2PreChomp = {
-"Apache::Template::TT2PreChomp", "",
-};
-static mod_perl_cmd_info cmd_info_TT2PostChomp = {
-"Apache::Template::TT2PostChomp", "",
-};
-static mod_perl_cmd_info cmd_info_TT2Trim = {
-"Apache::Template::TT2Trim", "",
-};
-static mod_perl_cmd_info cmd_info_TT2AnyCase = {
-"Apache::Template::TT2AnyCase", "",
-};
-static mod_perl_cmd_info cmd_info_TT2Interpolate = {
-"Apache::Template::TT2Interpolate", "",
-};
-static mod_perl_cmd_info cmd_info_TT2IncludePath = {
-"Apache::Template::TT2IncludePath", "",
-};
-static mod_perl_cmd_info cmd_info_TT2Absolute = {
-"Apache::Template::TT2Absolute", "",
-};
-static mod_perl_cmd_info cmd_info_TT2Relative = {
-"Apache::Template::TT2Relative", "",
-};
-static mod_perl_cmd_info cmd_info_TT2Delimiter = {
-"Apache::Template::TT2Delimiter", "",
-};
-static mod_perl_cmd_info cmd_info_TT2PreProcess = {
-"Apache::Template::TT2PreProcess", "",
-};
-static mod_perl_cmd_info cmd_info_TT2PostProcess = {
-"Apache::Template::TT2PostProcess", "",
-};
-static mod_perl_cmd_info cmd_info_TT2Process = {
-"Apache::Template::TT2Process", "",
-};
-static mod_perl_cmd_info cmd_info_TT2Wrapper = {
-"Apache::Template::TT2Wrapper", "",
-};
-static mod_perl_cmd_info cmd_info_TT2Default = {
-"Apache::Template::TT2Default", "",
-};
-static mod_perl_cmd_info cmd_info_TT2Error = {
-"Apache::Template::TT2Error", "",
-};
-static mod_perl_cmd_info cmd_info_TT2Tolerant = {
-"Apache::Template::TT2Tolerant", "",
-};
-static mod_perl_cmd_info cmd_info_TT2Variable = {
-"Apache::Template::TT2Variable", "",
-};
-static mod_perl_cmd_info cmd_info_TT2Constant = {
-"Apache::Template::TT2Constant", "",
-};
-static mod_perl_cmd_info cmd_info_TT2ConstantsNamespace = {
-"Apache::Template::TT2ConstantsNamespace", "",
-};
-static mod_perl_cmd_info cmd_info_TT2EvalPerl = {
-"Apache::Template::TT2EvalPerl", "",
-};
-static mod_perl_cmd_info cmd_info_TT2LoadPerl = {
-"Apache::Template::TT2LoadPerl", "",
-};
-static mod_perl_cmd_info cmd_info_TT2Recursion = {
-"Apache::Template::TT2Recursion", "",
-};
-static mod_perl_cmd_info cmd_info_TT2PluginBase = {
-"Apache::Template::TT2PluginBase", "",
-};
-static mod_perl_cmd_info cmd_info_TT2AutoReset = {
-"Apache::Template::TT2AutoReset", "",
-};
-static mod_perl_cmd_info cmd_info_TT2CacheSize = {
-"Apache::Template::TT2CacheSize", "",
-};
-static mod_perl_cmd_info cmd_info_TT2CompileExt = {
-"Apache::Template::TT2CompileExt", "",
-};
-static mod_perl_cmd_info cmd_info_TT2CompileDir = {
-"Apache::Template::TT2CompileDir", "",
-};
-static mod_perl_cmd_info cmd_info_TT2Debug = {
-"Apache::Template::TT2Debug", "",
-};
-static mod_perl_cmd_info cmd_info_TT2Headers = {
-"Apache::Template::TT2Headers", "",
-};
-static mod_perl_cmd_info cmd_info_TT2Params = {
-"Apache::Template::TT2Params", "",
-};
-static mod_perl_cmd_info cmd_info_TT2ServiceModule = {
-"Apache::Template::TT2ServiceModule", "",
-};
-
-
-static command_rec mod_cmds[] = {
-
- { "TT2Tags", perl_cmd_perl_TAKE12,
- (void*)&cmd_info_TT2Tags,
- RSRC_CONF | ACCESS_CONF, TAKE12, "tag style or start and end tags for template
directives" },
-
- { "TT2PreChomp", perl_cmd_perl_FLAG,
- (void*)&cmd_info_TT2PreChomp,
- RSRC_CONF | ACCESS_CONF, FLAG, "flag to remove newline and whitespace before
directives" },
-
- { "TT2PostChomp", perl_cmd_perl_FLAG,
- (void*)&cmd_info_TT2PostChomp,
- RSRC_CONF | ACCESS_CONF, FLAG, "flag to remove newline and whitespace after
directives" },
-
- { "TT2Trim", perl_cmd_perl_FLAG,
- (void*)&cmd_info_TT2Trim,
- RSRC_CONF | ACCESS_CONF, FLAG, "flag to trim whitespace surrounding template
output" },
-
- { "TT2AnyCase", perl_cmd_perl_FLAG,
- (void*)&cmd_info_TT2AnyCase,
- RSRC_CONF | ACCESS_CONF, FLAG, "flag to allow directive keywords in any case" },
-
- { "TT2Interpolate", perl_cmd_perl_FLAG,
- (void*)&cmd_info_TT2Interpolate,
- RSRC_CONF | ACCESS_CONF, FLAG, "flag to interpolate embedded variable
references" },
-
- { "TT2IncludePath", perl_cmd_perl_ITERATE,
- (void*)&cmd_info_TT2IncludePath,
- RSRC_CONF | ACCESS_CONF, ITERATE, "local path(s) containing templates" },
-
- { "TT2Absolute", perl_cmd_perl_FLAG,
- (void*)&cmd_info_TT2Absolute,
- RSRC_CONF | ACCESS_CONF, FLAG, "flag to enable absolute filenames" },
-
- { "TT2Relative", perl_cmd_perl_FLAG,
- (void*)&cmd_info_TT2Relative,
- RSRC_CONF | ACCESS_CONF, FLAG, "flag to enable relative filenames" },
-
- { "TT2Delimiter", perl_cmd_perl_TAKE1,
- (void*)&cmd_info_TT2Delimiter,
- RSRC_CONF | ACCESS_CONF, TAKE1, "alternative directory delimiter" },
-
- { "TT2PreProcess", perl_cmd_perl_ITERATE,
- (void*)&cmd_info_TT2PreProcess,
- RSRC_CONF | ACCESS_CONF, ITERATE, "template(s) to process before each main
template" },
-
- { "TT2PostProcess", perl_cmd_perl_ITERATE,
- (void*)&cmd_info_TT2PostProcess,
- RSRC_CONF | ACCESS_CONF, ITERATE, "template(s) to process after each main
template" },
-
- { "TT2Process", perl_cmd_perl_ITERATE,
- (void*)&cmd_info_TT2Process,
- RSRC_CONF | ACCESS_CONF, ITERATE, "template(s) to process instead of each main
template" },
-
- { "TT2Wrapper", perl_cmd_perl_ITERATE,
- (void*)&cmd_info_TT2Wrapper,
- RSRC_CONF | ACCESS_CONF, ITERATE, "template(s) to wrap around each main
template" },
-
- { "TT2Default", perl_cmd_perl_TAKE1,
- (void*)&cmd_info_TT2Default,
- RSRC_CONF | ACCESS_CONF, TAKE1, "default template to process when another
template is not found" },
-
- { "TT2Error", perl_cmd_perl_TAKE1,
- (void*)&cmd_info_TT2Error,
- RSRC_CONF | ACCESS_CONF, TAKE1, "template to process when an uncaught error
occurs" },
-
- { "TT2Tolerant", perl_cmd_perl_FLAG,
- (void*)&cmd_info_TT2Tolerant,
- RSRC_CONF | ACCESS_CONF, FLAG, "flag to set error tolerance for providers" },
-
- { "TT2Variable", perl_cmd_perl_TAKE2,
- (void*)&cmd_info_TT2Variable,
- RSRC_CONF | ACCESS_CONF, TAKE2, "define a template variable" },
-
- { "TT2Constant", perl_cmd_perl_TAKE2,
- (void*)&cmd_info_TT2Constant,
- RSRC_CONF | ACCESS_CONF, TAKE2, "define a constant variable" },
-
- { "TT2ConstantsNamespace", perl_cmd_perl_TAKE1,
- (void*)&cmd_info_TT2ConstantsNamespace,
- RSRC_CONF | ACCESS_CONF, TAKE1, "define variable namespace for constants" },
-
- { "TT2EvalPerl", perl_cmd_perl_FLAG,
- (void*)&cmd_info_TT2EvalPerl,
- RSRC_CONF | ACCESS_CONF, FLAG, "flag to allow PERL blocks to be evaluated" },
-
- { "TT2LoadPerl", perl_cmd_perl_FLAG,
- (void*)&cmd_info_TT2LoadPerl,
- RSRC_CONF | ACCESS_CONF, FLAG, "flag to allow regular Perl modules to be loaded
as plugins" },
-
- { "TT2Recursion", perl_cmd_perl_FLAG,
- (void*)&cmd_info_TT2Recursion,
- RSRC_CONF | ACCESS_CONF, FLAG, "flag to enable recursion into templates" },
-
- { "TT2PluginBase", perl_cmd_perl_ITERATE,
- (void*)&cmd_info_TT2PluginBase,
- RSRC_CONF | ACCESS_CONF, ITERATE, "packages in which to locate for plugins" },
-
- { "TT2AutoReset", perl_cmd_perl_TAKE1,
- (void*)&cmd_info_TT2AutoReset,
- RSRC_CONF | ACCESS_CONF, TAKE1, "flag to reset (clear) any BLOCK definitions
before processing" },
-
- { "TT2CacheSize", perl_cmd_perl_TAKE1,
- (void*)&cmd_info_TT2CacheSize,
- RSRC_CONF | ACCESS_CONF, TAKE1, "integer limit to the number of compiled
templates to cache in memory" },
-
- { "TT2CompileExt", perl_cmd_perl_TAKE1,
- (void*)&cmd_info_TT2CompileExt,
- RSRC_CONF | ACCESS_CONF, TAKE1, "filename extension for caching compiled
templates back to disk" },
-
- { "TT2CompileDir", perl_cmd_perl_TAKE1,
- (void*)&cmd_info_TT2CompileDir,
- RSRC_CONF | ACCESS_CONF, TAKE1, "path to directory for caching compiled
templates back to disk" },
-
- { "TT2Debug", perl_cmd_perl_FLAG,
- (void*)&cmd_info_TT2Debug,
- RSRC_CONF | ACCESS_CONF, FLAG, "flag to enable debugging" },
-
- { "TT2Headers", perl_cmd_perl_ITERATE,
- (void*)&cmd_info_TT2Headers,
- RSRC_CONF | ACCESS_CONF, ITERATE, "list of keywords indicating HTTP headers to
add" },
-
- { "TT2Params", perl_cmd_perl_ITERATE,
- (void*)&cmd_info_TT2Params,
- RSRC_CONF | ACCESS_CONF, ITERATE, "list of keywords indicating parameters to
add as template variables" },
-
- { "TT2ServiceModule", perl_cmd_perl_TAKE1,
- (void*)&cmd_info_TT2ServiceModule,
- RSRC_CONF | ACCESS_CONF, TAKE1, "name of class which implements template
service module" },
-
- { NULL }
-};
-
-module MODULE_VAR_EXPORT XS_Apache__Template = {
- STANDARD_MODULE_STUFF,
- NULL, /* module initializer */
- create_dir_config_sv, /* per-directory config creator */
- perl_perl_merge_dir_config, /* dir config merger */
- create_srv_config_sv, /* server config creator */
- perl_perl_merge_srv_config, /* server config merger */
- mod_cmds, /* command table */
- NULL, /* [7] list of handlers */
- NULL, /* [2] filename-to-URI translation */
- NULL, /* [5] check/validate user_id */
- NULL, /* [6] check user_id is valid *here* */
- NULL, /* [4] check access by host address */
- NULL, /* [7] MIME type checker/setter */
- NULL, /* [8] fixups */
- NULL, /* [10] logger */
- NULL, /* [3] header parser */
- NULL, /* process initializer */
- NULL, /* process exit/cleanup */
- NULL, /* [1] post read_request handling */
-};
-
-#define this_module "Apache/Template.pm"
-
-static void remove_module_cleanup(void *data)
-{
- if (find_linked_module("Apache::Template")) {
- /* need to remove the module so module index is reset */
- remove_module(&XS_Apache__Template);
- }
- if (data) {
- /* make sure BOOT section is re-run on restarts */
- (void)hv_delete(GvHV(incgv), this_module,
- strlen(this_module), G_DISCARD);
- if (dowarn) {
- /* avoid subroutine redefined warnings */
- perl_clear_symtab(gv_stashpv("Apache::Template", FALSE));
- }
- }
-}
-
-MODULE = Apache::Template PACKAGE = Apache::Template
-
-PROTOTYPES: DISABLE
-
-BOOT:
- XS_Apache__Template.name = "Apache::Template";
- add_module(&XS_Apache__Template);
- stash_mod_pointer("Apache::Template", &XS_Apache__Template);
- register_cleanup(perl_get_startup_pool(), (void *)1,
- remove_module_cleanup, null_cleanup);
-
-void
-END()
-
- CODE:
- remove_module_cleanup(NULL);
diff -ruN test.pl test.pl
--- test.pl 2001-06-12 13:38:23.000000000 -0400
+++ test.pl 1969-12-31 19:00:00.000000000 -0500
@@ -1,7 +0,0 @@
-BEGIN { $| = 1; print "1..1\n"; }
-END { print "not ok 1\n" unless $loaded; }
-use Apache::Template;
-$loaded = 1;
-print "ok 1\n";
-
-