Skip Menu |

This queue is for tickets about the Test-WWW-Mechanize-CGIApp CPAN distribution.

Report information
The Basics
Id: 53230
Status: open
Priority: 0/
Queue: Test-WWW-Mechanize-CGIApp

People
Owner: Nobody in particular
Requestors: JMERELO [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.05
Fixed in: (no value)



I have been trying to use this module with a CGIApp that connects to a database. It works well from the browser, but when using it from your module, I get two different errors. If I initialize the app this way:
my $custom_mech = Test::WWW::Mechanize::CGIApp->new;
  $custom_mech->app(
     sub {
       require "My::WebApp";
       my $app = My::WebApp->new();
       $app->fiddle_with_stuff();
       $app->run();
     });

The database handle seems to dissapear when actually calling the run mode. And I I create it in the usual way, via a class that initializes itself,
$mech->app( " Net::Lujoyglamour::WebApp::Test" );
When I arrive to this code in CGIApp: if (defined ($app)) {
    if (ref $app) {
      if (ref $app eq 'CODE') {
    &{$app};
      }
      else {
    die "The app value is a ref to something that isn't implemented.";
      }
    }
    else {
      # use eval since the module name isn't a BAREWORD
      eval "require " . $app;

      if ($app->isa("CGI::Application::Dispatch")) {
    $app->dispatch();
      }
      elsif ($app->isa("CGI::Application")) {
    my $app = $app->new();
    $app->run();
      }
      else {
    die "Unable to use the value of app.";
      }
    }

I obviously get an error indicating that you can't do an ->isa on a string. This seems an obvious bug, you are require'ing a string (a module name) and then you're using it as an object... The module above inherits indirectly from CGI::Application, not directly.

Cheers

JJ


El Mie Dic 30 07:40:42 2009, JMERELO escribió:
Show quoted text
> I have been trying to use this module with a CGIApp that connects to a
> database. It works well from the browser, but when using it from your
> module, I
> get two different errors. If I initialize the app this way:
> my $custom_mech = Test::WWW::Mechanize::CGIApp->new;
> $custom_mech->app(
> sub {
> require "My::WebApp";
> my $app = My::WebApp->new();
> $app->fiddle_with_stuff();
> $app->run();
> });
>
> The database handle seems to dissapear when actually calling the run
> mode.


In fact, this one seemed to solve itself; it's probably got nothing to do with your module, but when you use an in-memory database with SQLite, it dissapears half-way into the run. It's probably a CGI::Application problem, though. 

Cheers

JJ