On Wed, 21 Dec 2005, Gareth Kirwan wrote:
A while ago I raised a question about DBI disconnecting in cleanups of
inherited components, like autohandler,
and how the cleanup would not be executed.

Has anyone found a way round this?

I seem to remember Dave (I think) saying that this should be fixed
some time.

I don't remember the previous thread. I thought you could
just put

  # in httpd.conf
  PerlModule Apache::DBI

  # in %init of /autohandler
  local $dbh = DBI->connect(...);

and it automatically cleaned up.

Another way you can do anything around any request as of HTML::Mason 1.29
is to use HTML::Mason::Plugin. I had to figure out what exactly
"Plugins are activated by passing plugins in the interpreter or
request object" means. In httpd.conf:

  PerlAddVar MasonPlugins Plugins::One
  PerlAddVar MasonPlugins Plugins::Two

Or, the Interp constructor accepts arguments to Request, so you can do

  $interp = HTML::Mason::Interp->new(
      plugins => [qw(Plugins::One Plugins::Two)],
      etc..
  );

You can then pass the $interp to HTML::Mason::ApacheHandler's
constructor or call $interp->exec.
  Then in the plugin class, just add an end_request_hook subroutine.
You can normally access globals by something like

  $HTML::Mason::Commands::dbh

At least within the *_component_hook subroutines. Now that I think
about it, I'm not sure if those globals (e.g. $m and $r) would be
there during the *_request_hook ones.


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Mason-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to