After some playing around, here is new API I've come up. Please comment and
insult any piece that you wish :)

CGI::Application::Dispatch->dispatch(
  prefix => 'My::Project',
  table  => [
    ''               => { app => 'My::Project::Start', rm => 'start' },
    ':app/:rm'       => { },
    'admin/:app/:rm' => { prefix => 'My::Project::Admin' },
  ],
  args_to_new => {
    foo => 'bar',
    baz => 'bam',
  }
);

First off, all args are now lowercase (the reason CAD is currently STUDDLY CAPS
is because it was first written to run under mod_perl and I thought caps looked
better in the config file... oh well). Upper case args will still be valid, but
preference will be given to the lc'ed version first.

table - works just like the most recently proposed syntax for dispatching if an
array ref, else works just like CAD does now. If no table is specified, then
something like the following would be the default:

  [
    ''         => { app => $default },
    ':app/:rm' => {},
  ]

This should make it work by default like CAD does now.

prefix - same as CAD does now, but can be overridden in specific rules in 
'table'

args_to_new - passes these extra args to new(). Just for backwards
compatability, any extra args to dispatch() will be passed to new(), but a
warning about deprecation will be issued. args_to_new can also be overridden by
a specific rule.

:app - will be converted into the module name using the same current rules. So
  module_name
will become
  Module::Name
I'm also thinking about adding the rule that
  module-name
would become
  ModuleName

:rm - will not have any filtering applied to it

For the mod_perl side, TABLE is currently done as simple name-value pairs in the
 httpd.conf. I'm not sure if this should still be done the same way for this
version since you can't disambiguate between arrays or hashes coming from the
httpd.conf. It's all arrays. So I'm thinking about adding a mod_perl directive
to specify a class to use instead. This class would simply need to have an
accessible @TABLE variable. So something like:

  # in httpd.conf
  CGIAPP_DISPATCH_TABLE_CLASS MyProject::Dispatch

  # in MyProject/Dispatch.pm
  package MyProject::Dispatch;
  our @TABLE = (...);

I'm pretty sure at this point I can keep all of the old stuff functioning the
same if the old interface is used. But I would encourage users to use the new
API to accomplish the same goals.

   CGI::Application::Dispatch->dispatch();

And a url of /module_name/foo

Currently, and with the new API, maps to Module::Name->foo().

If anyone has anything that they are currently doing with the old API that they
are concerned will not translate over, please let me know. After a few versions
of the new API have been in the wild for a while the old stuff will start
issueing deprecation warnings, and then eventually will be removed (but not
anytime soon).

-- 
Michael Peters
Developer
Plus Three, LP



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

Reply via email to