"Michael Peters" <suppressed> ???????/???????? ? ????????
?????????: news:suppressed
>
>>
>> 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
Agree, it's hypertrophied a little, but it tends to be so.
>
>> 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.
Yes I can. I even can rewrite dispatcher from scratch. But I don't want to.
My hands are getting tired from typing. May be I'm lazy... ;-)
Simply, I want new CGI::Application::Dispatch will do The Right Things
and will be flexible enough to avoid subclassing in most cases.
That's what I propose. More detailed.
In our stuartup script we will define which module for which path to use.
No runmode or parameter defined.
===============================
CGI::Application::Dispatch->dispatch(
PREFIX => 'MyCgiApp::Modules',
TABLE => {
'default' => 'Default', # only path-module relation
'admin' => 'Admin',
'user' => 'User',
'etc.' => 'Etc',
}
);
===============================
In C::A module:
===============================
package MyCGIApp::Module;
use base 'CGI::Application';
use constant DISPATCH_TABLE => {
':app/view/:cat?/:id?/:type?' => {},
};
# or
sub DISPATCH_TABLE {
return {
':app/view/:cat?/:id?/:type?' => {},
};
}
....
===============================
In Dispatcher:
# somewhere after
$self->require_module($module);
...
my $dispatch_table = $module->DISPATCH_TABLE();
if ($dispatch_table) {
# Process dispatch table
# Define runmode, params, etc.
}
else {
do_something_other();
}
===============================
Thats it.
So we have our code & dispatch table scoped in one module. Separate for each
module. Almost as in Cat... another nice cgiapp framework.
It allow us to install/uninstall modules very easily. Almost like another
framework does.
It's "Compontent Auto-Discovery" and with Dispatcher without 'table' arg
it's full "Compontent Auto-Discovery" (yes, unsecure). Almost like... Well,
you guess...
---------------------------------------------------------------------
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.