On 2004-09-09, Michael Peters <[EMAIL PROTECTED]> wrote:
I'm currently calling it C::A::Dispatch. It based on the path it would create an instance of the correct class, give it the right run mode, and then run it...
So a request for something like this... /app/user_preferences/mode2
would be translated basically into these steps... require User::Preferences; my $app = User::Preferences->new(); $app->mode_param(sub {return 'mode2'}); $app->run();
I really like it cause there are no instance scripts. I know somepeople really like instance scripts but to me they seem like clutter. I have found that if move all configuration directives into config files they are easier for non programmers to edit and then I don't need instance scripts.
I like this idea. I think the important thing is to organize your code into separate modules, but separate instance scripts are less of issue.
I agree. That's why I wrote it. :)
It also seems like this could be implemented in such a way that you
could still use the same modules with "old fashioned" instance scripts
if desired.
Yeah, it imposes no retrictions on how the application module is actually developed. If someone publishes an application module you could invoke it with an instance script or with C::A::Dispatch. That's actually what I'm doing with CGI::Application::MailPage (by sam tregar).
I encourage you to publish this work. :)
It will be on CPAN this weekend hopefully.
BTW, here's a simple refactor of a line above:
$app->mode_param('mode2');
Actually I don't think that will do what I needed it to do. That will tell C::A to look at the value of the parameter named 'mode2' in the query string. I need it to use 'mode2' as the value not the name. I guess I could remove the explicit return, but that's about it. :)
$self->mode_param('rm', path_info => 1);
I like the idea, but I'm not always happy with passing in parameters where some are name-value and others aren't. Just to look at other options we could have
$self->mode_param(path_info => 1, default_param => 'rm');
I agree, I like your solution better, although I might shorten it a bit:
$self->mode_param(path_info => 1, default => 'rm');
Actually, since 'rm' is already a default, if you just want to declare that you want the "path_info" parsing, it could be this:
$self->mode_param(path_info => 1);
Both the current options take just one argument, which we can easily
detect.
Even better than my idea. Especially since if your going to use path_info do you really care about some parameters in the query string?
and then detect the number of args on the other side... or we could introduce a new method altogether like...
$self->mode_from_path(1);
I considered this option as well. However, I don't think it's a stretch for "mode_param" to also handle an option about how get the "mode_param()".
Yeah, I agree with the other idea above. There's no need to add another method here.
-- 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]
