Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: CGI::Application::Dispatch and 'default' run-modes

by tachyon (Chancellor)
on Nov 03, 2004 at 00:45 UTC ( [id://404798]=note: print w/replies, xml ) Need Help??


in reply to CGI::Application::Dispatch and 'default' run-modes

This module has a significant issue in that it does not let you set a default module and a default runmode if these are not passed. It needs patching to do so. It looks quite handy so I have patched it to accept default values (untested as yet). You would have to subclass all bar one function in it to get the same result so you really need to patch it. It looks like the author has not considered a desire for default behaviour.

103a104,106 > PerlSetVar CGIAPP_DEFAULT_RM Login > # Some::Module or Some_Module syntax OK > PerlSetVar CGIAPP_DEFAULT_DISPATCH Some_Module 123c126 < my $module = get_module_name($path, $dir_args->{CGIAPP_DISPATCH_ +PREFIX}); --- > my $module = get_module_name($path, $dir_args->{CGIAPP_DISPATCH_ +PREFIX}, $dir_args->{CGIAPP_DEFAULT_DISPATCH} ); 147c150 < my $rm = get_runmode($path); --- > my $rm = get_runmode($path, $dir_args->{CGIAPP_DEFAULT_RM}); 169a173,174 > DEFAULT_MODULE => 'Some_Module', # Some::Module or Some +_Module OK > DEFAULT_RM => 'Login', 192c197,198 < ($args{CGIAPP_DISPATCH_PREFIX} || $args{PREFIX}) --- > ($args{CGIAPP_DISPATCH_PREFIX} || $args{PREFIX}, > $args{CGIAPP_DEFAULT_MODULE} || $args{DEFAULT_MODULE} ) 203c209 < my $run_mode = get_runmode($ENV{PATH_INFO}); --- > my $run_mode = get_runmode($ENV{PATH_INFO},$args{CGIAPP_DEFA +ULT_RM}||$args{DEFAULT_RM}); 222c228 < my ($path, $prefix) = @_; --- > my ($path, $prefix, $default ) = @_; 226a233 > $module ||= $default; 230c237 < $module = join( '::', ( map { ucfirst } ( split( /_/, $modul +e ) ) ) ); --- > $module = join( '::', ( map { ucfirst } ( split( /[_:]+/, $m +odule ) ) ) ); 249c256,258 < return (split(/\//, shift))[2]; --- > my ( $path, $default ) = @_; > my $rm = (split(/\//, $path))[2]; > return defined $rm ? $rm : $default;

Seve as patch.txt, then run patch Dispatch.pm < patch.txt. Obviously this is if you are in the same dir as Dispatch.pm

cheers

tachyon

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://404798]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-23 07:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found