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

Re: [cgiapp] Re: feedback on CGI::Application::Dispatch



Viacheslav Sheveliov wrote:
> "Mark Stosberg" <suppressed>
> ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × ÎÏ×ÏÓÔÑÈ ÓÌÅÄÕÀÝÅÅ:
> news:suppressed
> 
>>I just tried out the developer release of CGI::Application::Dispatch
>>2.00, and I have to say I really like it.  It helped me to create
>>shorter, cleaner, URLs for my project, pulling together a larger
>>dynamic website in something more friendly.
> 
> ...skipped...
> 
> Sounds tasty, but IMHO writing dispatch table in startup script is not very
> scalable way.
> 
> Lets say we have 10 modules * 10 runmodes. It's 100 dispatch table entries.
> Furthermore, installing/uninstalling new modules now is more painfull
> procedure.

That's a little overblown. Most apps will only need a handful of entries in it's
dispatch table. In a new project of mine so far there are 8 modules with about 7
run modes a piece, and there are only 2 entries in my dispatch table.

I think Mark's example is just to show how un-limiting Dispatch is, but my usage
is (and probably will continue to be) much simpler.

> I think the best way - determining in dispatcher only module name and
> runmode. Remaining part of PATH_INFO should be parsed by module itself,
> cause it greatly depends on module logic.

You can do that too. Just don't create a dispatch table, and the default table
will do just what you described.

> Or we can determine dispatch table in module to be called. In dispatcher we
> know module name and can retrieve dispatch table as $Module::DISPATCH_TABLE
> or $Module->dispatch_table().

You can do this by subclassing. In a current project of mine I have a separate
class for my dispatch table.

  package MyApp::Dispatch;
  use base 'CGI::Application::Dispatch';
  use strict;
  use warnings;

  sub dispatch_args {
      return {
         prefix  => 'MyApp::Control',
         table   => [
              ''                      => { app => 'Public' },
              ':app/:rm?/:id?/:type?' => {},
          ],
      };
  }

  1;

And then in my httpd.conf

<Location /app>
  PerlHandler MyApp::Dispatch
</Location>

-- 
Michael Peters
Developer
Plus Three, LP


---------------------------------------------------------------------
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.