On Oct 18, 2006, at 3:17 PM, Michael Greenish wrote:
> For now, I have reverted to not using Apache2::Reload, which is
> kind of a shame since I am still in the development stages of my
> application.


Just have your handler call another sub, and do everything in there.
Apache2::Reload will definately pick up the changes

I'm attaching my working handlers below.

preview_check runs in an early apache hook- can't remember which one.

it sets up the environment, creates a PageUser ( aka $ctx ) and tests
the ctx object to see if it has the preview cookie set- redirected if
necessary.

handler runs during the expected mp output stage. it pulls
environment stuff from pnotes, dispatches the page to be processed,
and then prints output.

Everything I do in the main handler happens in the Page namespace.

On my tests just now, changes to package FindMeOn are never caught by
Apache2::Reload.

However, any changes to FindMeOn::Page (which checks for
permissions / dispatches / etc ) are always caught.

================================================== ===================

package FindMeOn;

sub preview_check {
my ( $r )= shift;
Apache2::RequestUtil->request($r);
my $apr= Apache2::Request->new( $r , DISABLE_UPLOADS=>1 ,
POST_MAX=>10_000 );
$r->pnotes( 'apr'=> $apr );
my $PageUser= FindMeOn::PageUser->new( $r , $apr );
$r->pnotes( 'PageUser'=> $PageUser );
# don't run this test on redirects
if ( $apr->location eq '/preview' ) {
return Apache2::Const::OK;
}
if ( !$PageUser->preview__can() )
{
$r->headers_out->set( Location=> '/preview/' );
$r->status(Apache2::Const::REDIRECT);
return Apache2::Const::REDIRECT;
}
return Apache2::Const::OK;
}
sub handler {
my ( $r )= shift;
my $PageUser= $r->pnotes('PageUser');
my $apr= $r->pnotes('apr');
my $Page= FindMeOn::Page->new( $PageUser );
$r->content_type('text/html');
eval {
$r->print( ${$Page->request__process()} );
$PageUser->finish() ;
};
if ( $@ ) {
$r->print( $@ );
return Apache2::Const:ONE;
}
return Apache2::Const::OK;
}