http://qs321.pair.com?node_id=578412


in reply to CGI::App dynamic runmodes/modules

I have to admit I don't understand the logic flow of your framework in detail, but I think what you want can be accomplished with CGI::Application::Dispatch. To make it work, you'd split up your web app into many smaller cgiapp modules, and route to them through the URL.

For our photo gallery site, we use this approach, and it works very well. As an example, I have the following classes:

EM::UI::Admin::Layout EM::UI::Admin::Report EM::UI::Admin::Upload
and my dispatch table looks something like this:
CGI::Application::Dispatch->dispatch( table => [ # admin apps '/admin' => { app => 'EM::UI::Admin', rm => 'ove +rview' }, '/admin/:app/:rm/:id?' => { prefix => 'EM::UI::Admin' }, # general public apps ':app/:rm/:id?' => { prefix => 'EM::UI::Public' }, ], );
That way, a url like http://example.com/admin/layout/overview would get dispatched to the "overview" run mode in EM::UI::Admin::Layout.

The advantage of this approach is that I can simply drop in a new cgiapp class with new functionality, and it will work out of the box. It also helps with maintenance, since the classes are generally fairly small, and only contain code related to a single feature.

Some other plugins you may want to look into - in case you don't know of them yet - are:

There are a lot more plugins, but these are the ones that help me the most in building scalable and maintainable web apps with CGI::Application.

Replies are listed 'Best First'.
Re^2: CGI::App dynamic runmodes/modules
by Ryszard (Priest) on Oct 16, 2006 at 06:44 UTC
    Cool rhesa, i'd not explored this possibility..

    The application framework i have is quite extensive taking into account session management, authorisation, authentication etc etc.

    Hopefully this is something i can build into it.. ;-)