Apache::ReadConfig and method handlers

2003-06-04 Thread Issac Goldstand
After a few fruitless days of fiddling with this, I find myself getting
nowhere...  Can anyone really explain how Apache::ReadConfig and/or direct
me to the source code (for handling the namespace, not the code for Perl
sections)
 
   Issac



Using Apache::ReadConfig and method handlers

2003-06-03 Thread Issac Goldstand
I want to assign a method handler from within the Apache::ReadConfig
namespace.  Right now, what I have is some function which somewhat
resembles:

package My::Object;
sub method1 {
  my $self=shift;
  package Apache::ReadConfig;
  no strict;
  $Location{'/some/URL/'} = {
 Options = '+ExecCGI',
 PerlHeaderParserHandler = sub {$self-some_other_method;}
};

But when I browse to /some/URL, some_other_method never gets called, let
alone by $self

Any advice?

  Issac



Re: Using Apache::ReadConfig and method handlers

2003-06-03 Thread Perrin Harkins
On Mon, 2003-06-02 at 11:36, Issac Goldstand wrote:
 I want to assign a method handler from within the Apache::ReadConfig
 namespace.  Right now, what I have is some function which somewhat
 resembles:
 
 package My::Object;
 sub method1 {
   my $self=shift;
   package Apache::ReadConfig;
   no strict;
   $Location{'/some/URL/'} = {
  Options = '+ExecCGI',
  PerlHeaderParserHandler = sub {$self-some_other_method;}
 };
 
 But when I browse to /some/URL, some_other_method never gets called, let
 alone by $self

What are you trying to do?  You know you can only do this sort of thing
during server startup, right?  After startup, you can still push
handlers but you have to do it differently.

- Perrin


Re: Using Apache::ReadConfig and method handlers

2003-06-03 Thread Issac Goldstand
- Original Message - 
From: Perrin Harkins [EMAIL PROTECTED]
 On Mon, 2003-06-02 at 11:36, Issac Goldstand wrote:
  I want to assign a method handler from within the Apache::ReadConfig
  namespace.  Right now, what I have is some function which somewhat
  resembles:
 
  package My::Object;
  sub method1 {
my $self=shift;
package Apache::ReadConfig;
no strict;
$Location{'/some/URL/'} = {
   Options = '+ExecCGI',
   PerlHeaderParserHandler = sub {$self-some_other_method;}
  };
 
  But when I browse to /some/URL, some_other_method never gets called, let
  alone by $self

 What are you trying to do?  You know you can only do this sort of thing
 during server startup, right?  After startup, you can still push
 handlers but you have to do it differently.


No - this is at startup.  It's also, to the best of my knowledge, the *only*
way to push handlers onto a dynamic URL (eg, where the URL is a variable) -
which is what I'm trying to do.

This worked fine when it was just:
PerlHeaderParserHandler = __PACKAGE__.::some_handler;

Now, I'm realizing it should be something more akin to:

PerlHeaderParserHandler = ref($self).-some_method;

But even that's not working...

  Issac



Re: Using Apache::ReadConfig and method handlers

2003-06-03 Thread Perrin Harkins
On Mon, 2003-06-02 at 15:19, Issac Goldstand wrote:
 No - this is at startup.  It's also, to the best of my knowledge, the *only*
 way to push handlers onto a dynamic URL (eg, where the URL is a variable) -
 which is what I'm trying to do.

I was referring to the $r-push_handlers method which you can use when
handling a request.

 
 This worked fine when it was just:
 PerlHeaderParserHandler = __PACKAGE__.::some_handler;
 
 Now, I'm realizing it should be something more akin to:
 
 PerlHeaderParserHandler = ref($self).-some_method;
 
 But even that's not working...

That doesn't look like the syntax in the docs:
http://perl.apache.org/docs/1.0/guide/config.html#Perl_Method_Handlers

Or here:
http://perl.apache.org/docs/1.0/guide/method_handlers.html

If you really want an object method and not a class method, you need to
do something like this:

PerlHeaderParserHandler = sub {
 my $r = shift;
 $self-some_method($r);
 }

I never use Apache::ReadConfig, so my syntax could be off, but hopefully you get the 
idea.

- Perrin


Re: Using Apache::ReadConfig and method handlers

2003-06-03 Thread Issac Goldstand
- Original Message - 
From: Perrin Harkins [EMAIL PROTECTED]
 On Mon, 2003-06-02 at 15:19, Issac Goldstand wrote:
  No - this is at startup.  It's also, to the best of my knowledge, the
*only*
  way to push handlers onto a dynamic URL (eg, where the URL is a
variable) -
  which is what I'm trying to do.

 I was referring to the $r-push_handlers method which you can use when
 handling a request.

 
  This worked fine when it was just:
  PerlHeaderParserHandler = __PACKAGE__.::some_handler;
 
  Now, I'm realizing it should be something more akin to:
 
  PerlHeaderParserHandler = ref($self).-some_method;
 
  But even that's not working...

 That doesn't look like the syntax in the docs:
 http://perl.apache.org/docs/1.0/guide/config.html#Perl_Method_Handlers

 Or here:
 http://perl.apache.org/docs/1.0/guide/method_handlers.html

 If you really want an object method and not a class method, you need to
 do something like this:

 PerlHeaderParserHandler = sub {
  my $r = shift;
  $self-some_method($r);
  }
Right - for $r-push_handlers, I  do that:.

$r-push_handlers(PerlFixupHandler,sub {return $self-uf_handler(@_);});
# A lot more elegant than the example in the Guide, IMHO

But that's not what's needed for Apache::ReadConfig, I think - Here, we
don't expect a sub reference, but rather the *name* of the routine (in the
Apache::ReadConfig namespace) which we want to run...  I'm still
experimenting.

  Issac