[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cgiapp] CAP Application Design suggestion




Michael Peters wrote:
Giannis Economou wrote:
MyBaseApp    is-a         CGI:App
MyApp            is-a         MyBaseApp

You don't need an intermediar MyApp. Just have MyBaseApp and have Cars
and Airplanes inherity from that.

It's better for me with the intermediate MyApp. Having those 2 steps in extending CAP (one in MyBaseApp and one in MyApp) suits me better for future reusability (for example, only basic configuration and initialization but no runmodes definitions at all in MyBaseApp and "must of the times to be there" runmodes in MyApp).
Cars                is-a          MyApp
Airplanes         is-a          MyApp

Both Cars and Airplanes implement a runmode named: 'registration'

I want to be able to call the right 'registration' runmode, according to
one query param (for example, 'type') that user requests. Example the
"http://www.example.com/app.pl?rm=registration&type=car"; to be handled
by the Cars 'registration' runmode.

I thought to do that in app.pl script (the instantiation script):
1. Use plain CGI to check for the 'type' query parameter
2. Do a simple dispatch like:
  my $app = undef;
  $app = Cars->new() if $type eq "car";
  $app = Planes->new() if $type eq "planes";
  $app->run();

I'm wondering if they are better ways to do the above (maybe inside a
CAP, without using the plain CGI for checking the 'type' param).
Any suggestions or ideas (always for a persistent environment like
mod_perl) are welcome...

Use CGI::Application::Dispatch (use the 2.0 version which is still
labled 'development' but which I've been using in production just fine)
so that your URLs can look something like (under normal CGI)

  /app.pl/car/registration
  /app.pl/airplane/registration

This kind of mapping is so common in CGI::Application::Dispatch that you
wouldn't even need your own custom dispatch table to deal with it.


Exactly what I was looking for and even better, at least by your description. Will go to check it out immediately!
Thank you!

G.


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
             http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.