RE: [ANNOUNCE] Apache::Dispatch-0.02
> > -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
> -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
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
[ANNOUNCE] Apache::Dispatch-0.02
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 README: NAME Apache::Dispatch - call PerlHandlers with the ease of CGI scripts SYNOPSIS httpd.conf: PerlModule Apache::Dispatch PerlFixupHandler Apache::Dispatch DispatchMode Safe DispatchMethod Handler DispatchAllow Custom DispatchDeny Apache Protected PerlModule Bar DispatchBase Bar DispatchMethod Prefix 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 there are two ways of configuring Apache::Dispatch: per-server: in httpd.conf: PerlModule Apache::Dispatch PerlFixupHandler Apache::Dispatch DispatchMode Safe DispatchMethod Handler DispatchAllow Test in browser: http://localhost/Foo the results are the same as if your httpd.conf looked like: SetHandler perl-script PerlHandler Foo per-location: in httpd.conf PerlModule Apache::Dispatch PerlModule Bar PerlFixupHandler Apache::Dispatch DispatchBase Bar DispatchMethod Prefix 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 The per-location configuration offers additional security and protection by hiding both the name of the package and method from the browser. Because any class under the Bar:: hierarchy can be called, one directive is be able to handle all the methods of Bar, Bar::Baz, etc... CONFIGURATION DIRECTIVES DispatchBase Applies on a per-location basis only. The base class to be substituted for the $r->location part of the uri. DispatchMethod Applies on a per-server or per directory basis. Each directory or virtual host will inherit the value of the server if it does not specify a method itself. It accepts the following values: Handler - Assume the method name is handler(), for example /Foo/Bar becomes Foo::Bar->handler(). This is the default value outside of directives configured with DispatchBase. Prefix- Assume the method name is the last part of the uri and prefix dispatch_ to the method name. /Foo/Bar becomes Foo->dispatch_bar(). This is the default value within directives configured with DispatchBase. Determine - The method may either be handler() or the last part of the uri prefixed with dispatch_. The method will be determined by first trying dispatch_method() then by trying handler(). DispatchMode Applies on a per-server basis, except where a directive is using DispatchBase. Values of the main server will be inherited by each virtual host. It accepts the following values: Safe- Allow only those methods whose namespace is explicitly allowed by DispatchAllow and explicitly not denied by DispatchDeny. This is the default. Brave - Allow only those methods whose namespace is explicitly not denied by DispatchAllow. This is primarily intended for development and ought to work quite nicely with Apache::StatINC. Its security is not guaranteed. DispatchAllow A list of namespaces allowed to be dispatched according to the above DispatchMethod and DispatchMode rules. Applies on a per-server basis, except where a directive is using DispatchBase. Values of the main server will be inherited by each virtual host. DispatchDeny A list of namespaces denied dispatch according to the above DispatchMethod and DispatchMode rules. Applies on a per-server basis, except where a directive is using DispatchBase. Values of the mai