The first version of this is now on CPAN, if anyone is interested in it.

Adam

Quoting [EMAIL PROTECTED]:


I've found myself writing similar bits of code repeatedly, and figure
what i'm doing is probably common enough that something like this
could have a place on CPAN.  I'm mostly curious about if the name is
appropriate.

This is just a base class designed to speed the implementation of
handlers that happen to work in this way.  I plan to do a subclass of
this that'll have the generic TT generation stuff i'm always using
stuck into it as well.  I could also see other generic base classes
like this that might want to make uri's differently.

The idea of this handler is basically to take $r->uri, and map that to
a function.  Similar to Apache::Dispatch, similar to what Catalyst
does and similar to about a lot of other code i'm sure.  This thing
does work slightly differently though, because i often need it to.

Here's a quick outline of what it does.

Given a request for /foo/bar/haha/hoho

It will loop through the split uri checking for the existance of
subroutines like this:

foo_bar_haha_hoho_page
foo_bar_haha_page
foo_bar_page
foo_page
index

As soon as it finds one, it uses that function to generate the page.
The part of the URI that isn't in the function name gets stuck into an
array reference and passed into the actual page generation function
function like this

$self->function($r,$uri_leftovers,$args)

$args is whatever you want it to be, and is generated by a call to
$self->init($r).

here's some code to look at:

http://kabob.ca/perl/DirBasedHandler.pm

Any input would be appreciated.  I don't really even know if anyone
other than me is writing ResponseHandlers in this fashion, or if
everyone is just using Registry, or one of the various frameworks.

Adam





Reply via email to