Re: Can't call method "is_initial_req" without a package or objectreference at .........

2003-06-17 Thread Geoffrey Young


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



Re: Can't call method "is_initial_req" without a package or objectreference at .........

2003-06-17 Thread Geoffrey Young


Martin Moss wrote:
All,

I'm having some problems with Apache giving me grief, or most probably me
getting my knickers in a complete twist.
I get the following error:-
Can't call method "is_initial_req" without a package or object reference at
.
It seems to happen when my URL ends like this:-

/somepath/16
but not when it ends like this:-
/somepath/16/
/somepath/16 is resollved by mod_dir to /somepath/16/ using an internal redirect, and...


  unless ($r->is_main )
  {
print STDERR "Apache::Request is not Main, Getting Main\n";
print STDERR Dumper($r);
$r=$r->main;
print STDERR "Main Apache::Request is:-\n";
print STDERR Dumper($r);
print STDERR "DECLINING\n";
return DECLINED;
  }
you're not returning an object from your constructor on internal redirects :)

HTH

--Geoff