You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by John ORourke <jo...@o-rourke.org> on 2006/08/01 16:45:28 UTC

Re: handlers [OT]

Michael Peters wrote:

>John ORourke wrote:
>  
>
>>You could even do something really clever and make it map URI onto
>>module - eg. so /debitor/contract/create calls
>>Debitor::Contract->create(), but that wouldn't be very secure!
>>    
>>
>
>You could use something like Apache::Dispatch to achieve this or
>CGI::Application::Dispatch if you want a to you CGI::Application to structure
>your project. And CGI::Application::Dispatch does this in a secure way, so you
>can control which modules can be mapped to URL and it's pretty flexible too.
>
>  
>
Excellent, I'd never heard of that.  I only found out about Class::DBI 
yesterday too - next thing you'll be telling me there's a guide that 
picks out the most useful CPAN modules to stop people reinventing the wheel!

John


Re: handlers [OT]

Posted by Jonathan Vanasco <jo...@2xlp.com>.
On Aug 1, 2006, at 10:45 AM, John ORourke wrote:
> Excellent, I'd never heard of that.  I only found out about  
> Class::DBI yesterday too - next thing you'll be telling me there's  
> a guide that picks out the most useful CPAN modules to stop people  
> reinventing the wheel!

Personally, I disliked the dispatch frameworks out there.  They did  
things I didn't like, didn't do things I needed, and were too hard to  
patch.

So naturally, I made my own wheel -- and it has killer rims.

Its not terribly difficult to roll your own inspired from what you  
like in the stuff out there.

My handler has a few config items like:

my  %URL_Dispatch= (
	'/'=> 'FindMeOn::Page::Core::Index',
);
my 	@URL_RegexDispatch= (
		# user main , by numeric id
		{
			'regex'=> qr/^\/user\/([\w]{10})[\/]?$/,
			'package'=> 'FindMeOn::Page::Core::User::Main',
			'id_fields'=> ['hex_id']
		},
);

Then I just parse the path , clean it up, and map it onto a module  
using a Page/Dispatch module i wrote.

The regex suff is damn inefficient right now.  I'm just looping an  
array. I need to update it to do a hierarchy to be limit my match  
pool- but its still pretty decent and works for me better than the  
other dispatch stuff out there.

FWIW, I'd suggest checking out Rose::DB::Object over Class::DBI - its  
not only much nicer to work with from the outset, but its easy to  
implement over an existing project.

Re: handlers [OT]

Posted by Michael Peters <mp...@plusthree.com>.

John ORourke wrote:
> 
> Michael Peters wrote:
> 
>> John ORourke wrote:
>>  
>>
>>> You could even do something really clever and make it map URI onto
>>> module - eg. so /debitor/contract/create calls
>>> Debitor::Contract->create(), but that wouldn't be very secure!
>>>   
>>
>> You could use something like Apache::Dispatch to achieve this or
>> CGI::Application::Dispatch if you want a to you CGI::Application to
>> structure
>> your project. And CGI::Application::Dispatch does this in a secure
>> way, so you
>> can control which modules can be mapped to URL and it's pretty
>> flexible too.
>>
>>  
>>
> Excellent, I'd never heard of that.  I only found out about Class::DBI
> yesterday too - next thing you'll be telling me there's a guide that
> picks out the most useful CPAN modules to stop people reinventing the
> wheel!

Yep there is. It's called perlmonks :)

-- 
Michael Peters
Developer
Plus Three, LP