You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Martin Moss <Ma...@btinternet.com> on 2003/04/02 19:39:43 UTC

[users@httpd] Method Handler Gives class string, not class Ref

All,

I'm trying to work out the exact process for method handlers. I have a
method handler, which has a 'new' subroutine and the following handler
process:-

#sub handler : method        #Either of these is fine??????
sub handler ($$)
{

  my ($self,$r)=@_;

  #unless (ref($self))
  #{
    #print STDERR "Making NEW Object!!!!!!!!!\n";
    #$self=$self->new();
  #}

    $r=Bficient::Apache::Request->instance($r);
  my $uh=$r->user_object();
  $self->{user}=$uh;    #Get Error Here!!!! (Can't use string
("Bficient::Admin::Apache::Home") as a HASH ref while "strict refs" in use
at)


    etc.....
}

The problem I have is that $self is a 'classname string' not a class object.
Is this right? I thought that $self should be an object reference.
I'd seen an example in the mod_perl cookbook which treats $self as an
object. So I thought the above code should work, but it doesn't it gives me
an error of

"Can't use string ("Bficient::Admin::Apache::Home") as a HASH ref while
"strict refs" in use at etc..."

I am pre-loading Bficient::Admin::Apache::Home in my startup.pl, as I must
dynamically load modules based upon configuration files.
my 'new' subroutine is:-

sub new
{
  # inherited by all classes
  my $proto = shift;
  my $args=shift;
  my $class = ref($proto) || $proto;
  my $self = {};

  #print STDERR "In Bficient::Apache::Object for
$class\ndefault_task=$_default_task;";
  bless $self, $class;

  if(exists($args->{lang_id}))
  {
    $self->{lh}=Bficient::Maketext->get_handle($class,$args->{lang_id});
  }
  else
  {

$self->{lh}=Bficient::Maketext->get_handle($class,Bficient::Conf::DEFAULT_LA
NGUAGE_ID);
  }

  $self->_check_framework_methods();

  return $self;
}


Can anybody tell me If I'm assuming something that isn't or have I done
something wrong.

Kind regards

Marty


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org