kelkoon has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I'm evaluating Titanium for using it as a Web Framework. Titanium is a package including CGI::Application and several plugins. I'm not able to access to the diferent runtimes. May be the error is in the Dispatch module. I've done a small CGI::Application and routes work there (with format /helloworld.cgi-app2.pl?rm=mode3&calling_mode=2). I'd like to have more beatifull URL like /Application/Runmode/Parameter. This code is the HTTP server executed using CGI::Application::Server:
use warnings; use strict; use CGI::Application::Server; use lib 'lib'; use Shop; use CGI::Application::Dispatch; CGI::Application::Dispatch->dispatch(); sub dispatch_args { return { prefix => '', table => [ '' => { app => 'Shop', rm => 'products' }, ':app/:rm' => { }, 'admin/:app/:rm' => { prefix => 'MyApp::Admin' }, ], }; } my $app = Shop->new(PARAMS => { }); my $server = CGI::Application::Server->new(); #$server->document_root('./t/www'); $server->entry_points({ '/index.cgi' => $app, }); $server->run;
This code is the Application:
# In "Shop.pm"... package Shop; use base 'Titanium'; sub setup { my $c = shift; $c->start_mode('families'); $c->error_mode('fallo'); $c->run_modes([qw/ families products fallo /]); } sub families { my $c = shift; my $errs = shift; my $plantilla = $c->load_tmpl; $plantilla->param( TITULO_PAGINA => 'titulo', CUERPO_PAGINA => 'cuerpo', ); return $plantilla->output; } sub products { my $c = shift; my $plantilla = $c->load_tmpl; $plantilla->param( TITULO_PAGINA => 'olutit', CUERPO_PAGINA => 'opreuc', ); return $plantilla->output; } sub fallo { my $c = shift; my $plantilla = $c->load_tmpl; $plantilla->param( TITULO_PAGINA => 'FALLO fallo FALLO', CUERPO_PAGINA => 'error ERROR error', ); } 1;
Can you find what i'm missing? Thank you, Kelkoon

Replies are listed 'Best First'.
Re: Titanium problem
by Anonymous Monk on Apr 14, 2010 at 07:26 UTC
    I'm not able to access to the diferent runtimes.

    I don't see where you try to do it

      Hello, I'm traying ot access the sever throug a web server with the following URL:
      http://127.0.0.1:8080/index.cgi/Shop

      But If I try to access not the default runmode:
      http://127.0.0.1:8080/index.cgi/products

      It still access the default runmode "families".


      Thank you
        Arent you supposed to put those in your dispatch table?