Jay Truesdale wrote:

> On 8/18/06, Jeremy Blain <[EMAIL PROTECTED]> wrote:
>
>> Jay Truesdale wrote:
>>
>> >So, it is considered 'good practice' or 'required practice' to do an
>> >untie at the end of a request?
>> >
>> >I can put this in a <%cleanup> section of the final compoent in the
>> >call tree, correct?
>> >
>> >
>> >
>> I would suggest doing it further up the chain than that.  If you have
>> your own
>> ApacheHandler object, that may be the best place, being sure to catch
>> errors in
>> an eval block, and be sure it gets untied.
>
>
> Are there any complete code examples of this anywhere? I wrote my code
> based on the sample application in the Mason Book and there were no
> examples of using your own ApacheHandler object.

A simple handler might look like this.  Check the site docs for
more info.

-----
package My::ApacheHandler;
use strict;
use HTML::Mason::ApacheHandler;

my $ah = HTML::Mason::ApacheHandler->new(
  comp_root => '/webdata/',
  data_dir => '/var/mason',
  error_mode => 'fatal',
  allow_globals => [ qw( %SESSION ) ],
);

sub handler {
  my ($r) = @_;
 
  # do your session tying here

 
  # handle the actual request
  my $result = eval {
    $ah->handle_request($r);
  };
  if (my $err = $@) {
    # do something with the error
    # I have it logged and emailed
    # with a rate limiter to prevent
    # crazyness if things go to hell
  }


  # do session cleanup here

 
  # return the result.
  return $result;
}

1;

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Mason-users mailing list
Mason-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to