On 7/5/05, Jason Purdy <[EMAIL PROTECTED]> wrote:
> I'm working on the BREAD framework and I have the callback thing working
> and it's creating runmodes, but when the first one ('start') is trying
> to be called, I get:
> 
> $ perl -I/home/jason/cpan/CAP-Bread/lib index.cgi
> CGI::Application::Plugin::BREAD::bread_db() called!
> CGI::Application::Plugin::BREAD::register_runmodes() called!
> 
> Error executing run mode 'start': Can't locate object method "start" via
> package "MyBREADApp" at /usr/share/perl5/CGI/Application.pm line 154.
>   at index.cgi line 8
> 
> So I have my dynamic 'start' runmode defined in the Plugin and the
> cgiapp is looking for it in the base class, but I have it defined in the
> Plugin class.

This is a bit tricky, cause really you need to export that 'start'
method to the base class for it to work, and that could be dangerous,
since the user may want to override this start method.

What you can do is hardcode the reference to the function.  In your
plugin, set the runmode using $self->runmodes( start => \&start ). 
That will force CGI::App to use your start method.

But that completely stops the user from overriding your start method
(unless they call $self->runmodes(start => 'my_start_mode') sometime
later...

What I would probably do is use the reference technique, and then
offer a configuration option that allows the user to choose another
runmode to be called in place   $config = { START_MODE =>
'my_start_mode' }

Then in the location where you register the runmode, you use your
hardcoded start method if there is no config option.

Does that sound reasonable?

Cheers,

Cees

---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/[email protected]/
              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