[This is an Apache::Template question]

I have been experimenting with subclassing
Template::Service::Apache so that i can add
cookie/session support to my application. I have
tried Template::Plugin::Apache::SessionManager
with no luck, and  am resorting to rolling my own
support. Here is what i have so far:

I have deduced that
Template::Service::Apache::params() is where i
need to test for the existance of a session_id in
the cookie, but i can't pass the created
Apache::Session object to my template. Here is my
params() method:

sub params {
   my ($self,$r) = @_;

   # i tried calling super via $self->SUPER ...
but it didn't work
   my $params =
Template::Service::Apache::params(@_);

   my $request = Apache::Request->new($r);
   my %cookie  = Apache::Cookie->new($r)->parse;
   my $sess_id = $cookie{SESSION_ID};

   tie(my
%session,'Apache::Session::File',$sess_id, { 
      Directory     => $SESSION_DIR,
      LockDirectory => $SESSION_DIR,
   }) || die "Global data not available: $!";   

   warn "[params] session = ",
Data::Dumper::Dumper(\%session), "\n";

   # here is where the trouble seems to be
   $self->{SESSION}       = {%session};
   $params->{SESSION} = {%session};
   $params->{FOO}          = {bar=>'baz'};
   return $params;
}

If you look at the last 5 lines, i am setting a
key in both
$params and $self. $params is suppose to be
available to my templates, and i figure i need to
also store the sesssion in $self so that i can
set the cookie value with it in 
Template::Service::Apache::headers() ... but i
digress.

The problem is that SESSION is 'empty' when i try
to display it in my template. The warn statement
above yields something like:

[params] session = {
   '_session_id' =>
'afaa6ec9ca80e9fb6eafba3804770728'
}

But there are no keys when i try to access [%
SESSION %] in my template. However, notice the
FOO that i assigned to $params? THAT does show up
in my template:

[% SESSION %]                             #
yields HASH (...)
[% SESSION._session_id %]        # nothing
[% FOO.bar %]                                #
yields 'baz'

Also, i have tried 'attaching' the session like
so:
   $self->{SESSION}       = \%session;
   $params->{SESSION} = \%session;

but the results are the same (it don't work). Any
thoughts, suggestions, work-arounds, or MU's are
welcome. :)

thanks,
jeffa

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to