RE: [ANNOUNCE] Apache::Dispatch-0.02

2000-08-02 Thread Geoffrey Young

> > -Original Message-
> > From: Matt Sergeant [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, August 01, 2000 9:46 AM
> > To: Geoffrey Young
> > Cc: '[EMAIL PROTECTED]'
> > Subject: Re: [ANNOUNCE] Apache::Dispatch-0.02
> > 
> > 
> > 
> > You're gonna hate me for this...
> > 
> > Can you add pre and post methods for the dispatching? It 
> > would be really
> > useful to be able to (for example) save and restore 
> $SIG{__DIE__}, and
> > maybe other things like that, rather than having to 
> > explicitly remember to
> > call them yourself.
> 
> ok, I'll work on adding pre_dispatch() and post_dispatch() 
> (and possibly
> dispatch_error) calls to the existing framework and see what 
> I can come up
> with...
> 
> --Geoff
> 

well, I wasn't able to get that functionality into the existing design, but
that's ok because I wasn't too happy with it anyway :)

http://morpheus.laserlink.net/~gyoung/modules/Apache-Dispatch-0.03.tar.gz

is the new version.  I haven't uploaded it yet because I wanted to ask
anyone interested whether they are terribly upset that the API will be
changing and Apache::Dispatch won't support per-server handler calling.
Basically, you'll still need at least one , since in
order to get pre and post processing in, we had to move to PerlHandler from
PerlFixupHandler.

anyway, here's the new README.  I think the code generally cleaner than what
came before, so I'll upload it later in the week if nobody speaks up and
objects :)

--Geoff

NAME

Apache::Dispatch - call PerlHandlers with the ease of CGI scripts

SYNOPSIS

httpd.conf:

  PerlModule Apache::Dispatch
  PerlModule Bar

  
SetHandler perl-script
PerlHandler Apache::Dispatch

DispatchPrefix Bar
DispatchExtras Pre Post Error
  

DESCRIPTION

Apache::Dispatch translates $r->uri into a class and method and runs
it as a PerlHandler.  Basically, this allows you to call PerlHandlers
as you would CGI scripts - directly from the browser - without having
to load your httpd.conf with a slurry of  tags.

EXAMPLE

  in httpd.conf

PerlModule Apache::Dispatch
PerlModule Bar


  SetHandler perl-script
  PerlHandler Apache::Dispatch

  DispatchPrefix Bar
  DispatchExtras Pre Post Error


  in browser:
http://localhost/Foo/baz

  the results are the same as if your httpd.conf looked like:

   SetHandler perl-script
   PerlHandler Bar::dispatch_baz


  This configuration offers additional security by protecting the
  class from the browser and keeping the method name from being
  called directly. Because any class under the Bar:: hierarchy can be
  called, one  directive is able to handle all the methods
  of Bar, Bar::Baz, etc...

CONFIGURATION DIRECTIVES

  DispatchPrefix
Applies on a per-location basis only.  The base class to be 
substituted for the $r->location part of the uri.

  DispatchExtras
A list of extra processing to enable per-request.  They may be
applied on a per-server or per-location basis.  If the main
handler is not a valid method call, the request is declined prior
to the execution of any of the extra methods.

  Pre   - eval()s Foo->pre_dispatch() prior to dispatching the uri
  uri.  The $@ of the eval is not checked in any way.

  Post  - eval()s Foo->post_dispatch() prior to dispatching the
  uri.  The $@ of the eval is not checked.

  Error - If the main handler returns other than OK then 
  Foo->error_dispatch() is called and return status of it
  is returned instead.  Without this feature, the return
  status of your handler is returned.

SPECIAL CODING GUIDELINES

Apache::Dispatch uses object oriented calls behind the scenes.  This 
means that you either need to account for your handler to be called
as a method handler, such as
  sub dispatch_bar {
my $class = shift;  # your class
my $r = shift;
  }

or get the Apache request object yourself via

  sub dispatch_bar {
my $r = Apache->request;
  }

NOTES

In addition to the special methods pre_dispatch(), post_dispatch(),
and error_dispatch(), if you define dispatch_index() it will be called
if the method is empty (eg, by /Foo or /Foo/).

There is no require()ing or use()ing of the packages or methods prior
to their use as a PerlHandler.  This means that if you try to dispatch
a method without a PerlModule directive or use() entry in your 
startup.pl you probably will not meet with much success.  This adds a
bit of security and reminds us we should be pre-loading that code in
the parent process anyway...

If the uri can be dispatched but contains anything other than
[a-zA-Z0-9_/-] Apache::Dispatch declines to handle the request.

Like everything in perl, the package names are case sensit

RE: [ANNOUNCE] Apache::Dispatch-0.02

2000-08-01 Thread Geoffrey Young



> -Original Message-
> From: Matt Sergeant [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, August 01, 2000 9:46 AM
> To: Geoffrey Young
> Cc: '[EMAIL PROTECTED]'
> Subject: Re: [ANNOUNCE] Apache::Dispatch-0.02
> 
> 
> 
> You're gonna hate me for this...
> 
> Can you add pre and post methods for the dispatching? It 
> would be really
> useful to be able to (for example) save and restore $SIG{__DIE__}, and
> maybe other things like that, rather than having to 
> explicitly remember to
> call them yourself.

ok, I'll work on adding pre_dispatch() and post_dispatch() (and possibly
dispatch_error) calls to the existing framework and see what I can come up
with...

--Geoff

> 
> -- 
> 
> 
> Fastnet Software Ltd. High Performance Web Specialists
> Providing mod_perl, XML, Sybase and Oracle solutions
> Email for training and consultancy availability.
> http://sergeant.org | AxKit: http://axkit.org
> 



Re: [ANNOUNCE] Apache::Dispatch-0.02

2000-08-01 Thread Matt Sergeant

On Tue, 1 Aug 2000, Geoffrey Young wrote:

> The URL
> 
>  
> http://morpheus.laserlink.net/~gyoung/modules/Apache-Dispatch-0.02.tar.gz
> 
> has entered CPAN as
> 
>   file: $CPAN/authors/id/G/GE/GEOFF/Apache-Dispatch-0.02.tar.gz
>   size: 6362 bytes
>md5: 922a0064a77148d72aa29d3a9cc5db25
> 
> Revision history for Perl extension Apache::Dispatch
> 
> 0.01  7.28.2000
> - original version
> - many kudos and thanks to:
> Vivek Khera
> Matt Sergeant
>   for the initial ideas and impetus
> 
> 0.02  8.1.2000
> - thanks again to Matt Sergeant for input not limited to
>   the following valuable suggestions
> o add DispatchBase for dispatching on a protected,
>   per-location basis
> o add DispatchMethod Prefix for protecting methods
>   behind a dispatch_ prepend
> - changed behavior of directory and server merges
> - updated the documentation

You're gonna hate me for this...

Can you add pre and post methods for the dispatching? It would be really
useful to be able to (for example) save and restore $SIG{__DIE__}, and
maybe other things like that, rather than having to explicitly remember to
call them yourself.

-- 


Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org | AxKit: http://axkit.org