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


In reply to Re: CGI::Application::Dispatch and 'default' run-modes by tachyon
in thread CGI::Application::Dispatch and 'default' run-modes by geektron

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.