On Tue, 19 Aug 2003 20:34:50 -0700 (PDT)
Jeff Anderson <[EMAIL PROTECTED]> wrote:
Hi Jeff,
> On a related note, i tried
> Template::Plugin::Apache::SessionManager but
> couldn't get it to work. I did get the mod_perl
> example listed in the Apache::SessionManager to
> work, by the way, but not the Template plugin
> version
T::P::A::SM 0.02 pod contains a complete tutorial on using it with
Apache::Template. Have you also read it?
BTW, as Randal says, there isn't a way to set cookie directly from your
templates without writing (or patching) additional code.
T::P::A::SM set (and get) cookies because it works in a separate Apache
request phases (Header parsing or URI translation).
In order to solve your problem, this is a simple patch to Apache/Template.pm
(0.06) in order to define $r Apache request object as 'request' template
variable:
---CUTE HERE---
--- Template.pm Wed Aug 20 16:46:17 2003
+++ Template.pm-patched Wed Aug 20 16:39:45 2003
@@ -82,6 +82,7 @@
return $template unless ref $template;
my $params = $SERVICE->params($r);
+ $params->{ request } = $r;
return $params unless ref $params;
my $content = $SERVICE->process($template, $params);
---CUTE HERE---
Then you can set cookies in your TT2 files by using $r methods:
---CUTE HERE---
[% request.header_out('Set-Cookie','YOURCOOKIE1=foo; path=/baz') %]
<!-- or -->
[% request.err_header_out('Set-Cookie', 'YOURCOOKIE2=foo; path=/bar') %]
---CUT HERE---
Previous patch is very simple and it defines always the 'request' variable.
Next patch (to Template/Service/Apache.pm) allows a fine control whenever
or not you want to pass the $r object to templates by adding 'request'
keyword to 'TT2Params' directive (in httpd.conf):
---CUTE HERE---
--- Apache.pm Wed Aug 20 17:50:43 2003
+++ Apache.pm-patched Wed Aug 20 17:49:58 2003
@@ -136,6 +136,9 @@
grep(!/^$/, split(/;\s*/, $request->header_in('cookie'))),
} if $all or $plist->{ cookies };
+ $params->{ request } = $request
+ if $all or $plist->{ request };
+
# add any error raised by main template failure
$params->{ error } = $self->{ TEMPLATE_ERROR };
---CUTE HERE---
>... besides, it didn't play nice with
> tpage which complained about Apache not being
> loaded. Makes sense, but i don't see an immediate
> work around.
I don't understand why you need Apache modules (and cookies)
with tpage tools... :-)
by
- Enrico
_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://lists.template-toolkit.org/mailman/listinfo/templates