I sent this to the Template Toolkit list but got no responses.  I'm
pretty sure it is a mod_perl issue, but I can't for the life of me
figure out why the object doesn't get destroyed in the mod_perl
context.  A standalone test program always destroys the object at the
expected time.

This bug happens even under httpd -X.

--original message--

I have a plugin I'm writing to access an Apache::Session::MySQL
object.  What I do is create a hash that contains the fields
"_CONTEXT" pointing to the context, "verbose" being a debug flag, and
"_session" being a reference to the tied hash from
Apache::Session::MySQL.  The constructor looks something like this:

  my $self = { _CONTEXT => $context, verbose => 0 };

  bless $self, $class;

  # do the tie, error checks, etc.

  $self->{_session} = \%session;
  return $self;

Now I have a handler in mod_perl that runs *.mlm files through $tt,
which is a TT object that has pre/post process, plugin path, and some
global stash variables pre-defined.

This works fine from my templates:

[% USE s = session %]

[% s.stepsdone = s.stepsdone + 1 %]
<P>steps done = [% s.stepsdone %]</P>

However, at the end of the template processing, the object is not
destroyed; that is, the DESTROY() method is never called, and
therefore the tied hash never gets untied and  Apache::Session::MySQL
doesn't get a chance to write the data back to the store.

But.... when I kill httpd, all the objects created are then destroyed
(my DESTROY() has a debug statement that gets printed) and the session
is saved to the database (albeit, all identical since each new object
read the original data rather than the updated values).

It matters not whether I [% PROCESS %] or [% INCLUDE %] the template
that instantiates this object.

I tried to isolate a case of this in its own program, but of course
the object was destroyed every time...

Any ideas on where to trace this down?

Reply via email to