Hi George --
> $self->param('buttons' => ['Create', 'Read',
> 'Update', 'Delete']);
> $self->runModePerButton();
My $0.2:
Do you find it at all suspicious that you have replaced the whole concept of
run modes with these "buttons"? Effectively, that it what you have done.
Instead of specifying run_modes(), you now have buttons from which run-modes
are derived. Instead of looking at a run-mode parameter, you look at the
button name to figure out what to do next.
These should be hints to you that you are working "against the grain" of how
CGI::Application expects you to work. I am sure that you can hack together
something which will work using your techniques, but at what cost? By the
time you are done, you will have gutted CGI::Application and effectively
created your own system. Is this really what you want to do? I am a strong
believer in sticking with the "spirit" of whatever system I am trying to
use. CGI::Application has a way is expects programs to work, and that is
not exactly like the system you've created.
The best metric of how close you are to the spirit of CGI::Application's
desired mode of behavior is the size of your setup() method. A small
setup() method indicates that you are working with CGI::Application. A
large setup() method suggests that you are working against it. For example,
if I were writing an app similar to what you are trying to do, my setup
would look something like this:
sub setup {
my $self = shift;
$self->run_modes(
'create' => \&create,
'read' => \&read,
'update' => \&update,
'delete' => \&delete,
);
$self->start_mode('read');
$self->mode_param('rm');
}
Observe: Small in size; no black magic.
Everything else would be handled by setting the form parameter 'rm' to the
appropriate value. That would be done in my run-mode methods. I would not
try to connect the text on a submit button to the run-mode, when creating a
"hidden" form field containing the run-mode I want is so trivial:
<form>
<input type="hidden" name="rm" value="create">
<input type="button" value="Create a new Whatever">
</form>
My suggestion to you is to take a step back and evaluate whether or not
CGI::Application is helping you. What is it you are trying to achieve by
using CGI::Application? Are you using it for what it is good for
(specifically: Managing run-modes and providing a common architecture), or
are you bending it into a pretzel which only makes your job more difficult
and eliminates any benefit you would have otherwise gained from using
CGI::Application?
Obviously, I do not want to discourage you from using CGI::Application. I
just want to make sure it is making your job easier -- not harder.
Warmest regards,
-Jesse-
----
Jesse Erlbaum, CTO
Vanguard Media
212.242.5317 x115
[EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]