I think I have finally tracked down the problem I have been seeing
when using CGI::Application::Dispatch with
CGI::Application::Plugin::AutoRunmode.  CAP::AutoRunmode was failing
to register my runmodes whenever I used CA::Dispatch.

There is a very simple solution for this.  Just load
CGI::Application::Plugin::AutoRunmode inside of the dispatch script. 
That seems to solve the problem for me.

Following is a test case that shows the problem:

sample.cgi
---------------------------------
#!/usr/bin/perl

use strict;
use warnings;
use lib qw(.);

use CGI::Carp qw(fatalsToBrowser);
######use CGI::Application::Plugin::AutoRunmode;
use CGI::Application::Dispatch;

CGI::Application::Dispatch->dispatch(
    TABLE  => {
        'sample' => 'Sample',
    },
    DEFAULT => '/sample',
);
---------------------------------

Sample.pm
---------------------------------
package Sample;

use base qw(CGI::Application);

use CGI::Application::Plugin::AutoRunmode;
use CGI::Carp qw(fatalsToBrowser);

sub one : StartRunmode {
    my $self = shift;

    return CGI::start_html( )
        . CGI::h2('Sample page one')
        . CGI::a( { -href => $self->query->url().'/sample/two' },
'goto page two' )
        . CGI::end_html();
}

sub two : Runmode {
    my $self = shift;

    return CGI::start_html( )
        . CGI::h2('Sample page two')
        . CGI::a( { -href => $self->query->url().'/sample/one' },
'goto page one' )
        . CGI::end_html();
}

1;
---------------------------------

If you call sample.cgi you will end up seeing the default 'start' page
that CGI::Application provides instead of the StartRunmode that we
marked.  If you first load AutoRunmode in the sample.cgi script, then
you will see the correct page.

Cheers,

Cees

---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/cgiapp@lists.erlbaum.net/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to