Thanks Geoffrey. Marty ----- Original Message ----- From: "Geoffrey Young" <[EMAIL PROTECTED]> To: "Martin Moss" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Tuesday, June 17, 2003 4:23 PM Subject: Re: Can't call method "is_initial_req" without a package or object reference at .........
> > > Martin Moss wrote: > > Ok, that makes sense, thank you:-) > > But 'What' should I return, is $r->main the right thing to return? > > I've found that it's pretty rare that you want to mess with main vs subrequest logic > yourself. instead, I would just make the constructor return an object based on whatever > mod_perl passes it which is, in turn, whatever request record Apache deems to be the > proper one for the current (sub)request. > > so new() should probably just be something like > > sub new { > > my ($class, $r) = @_; > > $r = Apache::Request->new($r); > > my $self = bless {_r => $r}, $class; > > $self->init(); > > return $self; > } > > if it is important to insure that you only populate object attributes once, even in the > case of internal redirects or lookups, you could hang attributes off of pnotes in the main > request > > sub init { > > my $self = shift; > > $t = ubstr(Digest::MD5...); > > if ($r->main) { > $self->{XX_created_time_XX} = $t; > $self->{_r}->pnotes(XX_created_time_XX => $t) > } > else { > $t = $self->{_r}->main->pnotes('XX_created_time_XX'); > } > ... > } > > or somesuch. untested, but you get the idea :) > > HTH > > --Geoff > >