Re: [cgiapp] running modes in sequence
On Mon, Dec 12, 2005 at 10:45:27PM -0500, [EMAIL PROTECTED] wrote: Of course, I could call 'editproject' from 'saveproject', but that defeats the modularity of the script. Or enhances it. A run-mode does a few things. It does some work, and then returns results. It's best to partition those jobs. So youu might have: sub edit_mode { my $self = shift; $self-some_work(); return $self-edit_mode_results(); } sub final_mode { my $self = shift; $self-some_other_work; return $self-final_mode_results(); } sub both_mode { my $self = shift; $self-some_work(); $self-some_other_work(); return $self-final_mode_results(); } If you end up defining your work methods well, they'll be MORE modular (less tied to a given run_mode, and thus more reusable). Of course, I have a lot of templating work that happens at the end of a run_mode, so it's pretty much very undesirable for me to erven think of calling two in a row in one request. YMMV. -- SwiftOne / Brett Sanger [EMAIL PROTECTED] - Web Archive: http://www.mail-archive.com/cgiapp@lists.erlbaum.net/ http://marc.theaimsgroup.com/?l=cgiappr=1w=2 To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[cgiapp] running modes in sequence
Hi all. New to CGI::App and am wondering how to do the following in C::A that I was doing with a switch statement previously. The old: SWITCH: for ($query-param('funct')) { /save project/ido { saveproject(); editproject(); last; }; } The above runs sub called 'saveproject' and then when completed runs 'editproject'. How do I run two runmodes in one trip to my application with C::A? The new: sub setup { $self-start_mode('menu'); $self-mode_param('rm'); $self-run_modes( 'menu' = 'adminmenu', 'save' = 'saveproject', ??? } Is there anyway to send a hash, something like: sub setup { $self-start_mode('menu'); $self-mode_param('rm'); $self-run_modes( 'menu' = 'adminmenu', 'save' = { 'step1' = 'saveproject', 'step2' = 'editproject'} } Of course, I could call 'editproject' from 'saveproject', but that defeats the modularity of the script. Thanks, Brad - Web Archive: http://www.mail-archive.com/cgiapp@lists.erlbaum.net/ http://marc.theaimsgroup.com/?l=cgiappr=1w=2 To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [cgiapp] running modes in sequence
Hi, Look into CGI::Application::Plugin::Forward, it does this. Usually after you finish a runmode that saves something, or deletes etc, you want to forward onto a function that draws your page, pulls in your variables and lists etc. This function is ideal for that. Jeff. On 12/12/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi all. New to CGI::App and am wondering how to do the following in C::A that I was doing with a switch statement previously. The old: SWITCH: for ($query-param('funct')) { /save project/ido { saveproject(); editproject(); last; }; } The above runs sub called 'saveproject' and then when completed runs 'editproject'. How do I run two runmodes in one trip to my application with C::A? The new: sub setup { $self-start_mode('menu'); $self-mode_param('rm'); $self-run_modes( 'menu' = 'adminmenu', 'save' = 'saveproject', ??? } Is there anyway to send a hash, something like: sub setup { $self-start_mode('menu'); $self-mode_param('rm'); $self-run_modes( 'menu' = 'adminmenu', 'save' = { 'step1' = 'saveproject', 'step2' = 'editproject'} } Of course, I could call 'editproject' from 'saveproject', but that defeats the modularity of the script. Thanks, Brad - Web Archive: http://www.mail-archive.com/cgiapp@lists.erlbaum.net/ http://marc.theaimsgroup.com/?l=cgiappr=1w=2 To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jeff MacDonald http://www.halifaxbudolife.ca http://www.nintai.ca - Web Archive: http://www.mail-archive.com/cgiapp@lists.erlbaum.net/ http://marc.theaimsgroup.com/?l=cgiappr=1w=2 To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]