Re: [Catalyst] Re: How to redirect before some code excute
On 10/26/06, Fayland Lam [EMAIL PROTECTED] wrote: Matt S Trout wrote: Fayland Lam wrote: Lee Standen wrote: It's a subroutine, right? Tried a return?such as: $c-res-redirect('http://www.yahoo.com'); return undef; Indeed I want to run the 'while' loop in backend. 'return' would not run the loop I think. $c-res-redirect(...); $c-finalize_headers; while loop or whatever here might do the trick no, it doesn't work. maybe there is something concerned with 'butter', it's not sent immediately. and I use mod_perl2, so I'd like to have a try of system. Thanks any way. It works if you manage to run your stuff after Catalyst calls $c-finalize() in handle_request(). Funny, I just wrote a hack, err, plugin yesterday which gives me the option to set up a hook that's called right after $c-finalize(). I'm not sure if this is the correct way to do it or if there are any side-effects, if any of the more experient Catalyst users/developers think its a good idea for a plugin, let me know and I'll can carve it up and release it. I use mod_perl and haven't had any trouble so far, this approach lets me delegate all the pre-fork management to apache. I have a Catalyst front-end which adds jobs to a queue like mentioned before in the thread and a another Catalyst server running XMLRPC that gets notified about incoming jobs and runs them after responding to the XMLRPC notification. In MyApp.pm: use Catalyst qw/AfterFinalize/; In a controller action somewhere: sub myaction : Local { $c-res-body('running job'); $c-after_finalize(sub { run_job() } ); } -- Eden Cardim Instituto Baiano de Biotecnologia Núcleo de Biologia Computacional e Gestão de Informações Biotecnológicas Laboratório de Bioinformática -- you seem to think that 'close enough' is close enough... please learn to be 'literal' around programming. merlyn - on irc.freenode.net#perl AfterFinalize.pm Description: Perl program ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Re: How to redirect before some code excute
Fayland Lam [EMAIL PROTECTED] wrote: Lee Standen wrote: It's a subroutine, right? Tried a return?such as: $c-res-redirect('http://www.yahoo.com'); return undef; Indeed I want to run the 'while' loop in backend. 'return' would not run the loop I think. Why do you want to run the loop in the background? What purpose will it serve? If we can learn your motivation, we can try to find you At Least One Way To Do It. Len. This transmission may contain information that is privileged, confidential, legally privileged, and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. Although this transmission and any attachments are believed to be free of any virus or other defect that might affect any computer system into which it is received and opened, it is the responsibility of the recipient to ensure that it is virus free and no responsibility is accepted by JPMorgan Chase & Co., its subsidiaries and affiliates, as applicable, for any loss or damage arising in any way from its use. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Re: How to redirect before some code excute
Hi, I think the idea is to start a long-running process based on a web- based trigger and allow the user to proceed on to do other things. In other systems a fork() would probably be in order. I'm curious also - is there a Catalyst specific way of doing something like that...? and if not, is there any danger in fork()ing inside a catalyst app? Jay On Oct 26, 2006, at 9:43 AM, [EMAIL PROTECTED] wrote: Fayland Lam [EMAIL PROTECTED] wrote: Lee Standen wrote: It's a subroutine, right? Tried a return?such as: $c-res-redirect('http://www.yahoo.com'); return undef; Indeed I want to run the 'while' loop in backend. 'return' would not run the loop I think. Why do you want to run the loop in the background? What purpose will it serve? If we can learn your motivation, we can try to find you At Least One Way To Do It. Len. This transmission may contain information that is privileged, confidential, legally privileged, and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. Although this transmission and any attachments are believed to be free of any virus or other defect that might affect any computer system into which it is received and opened, it is the responsibility of the recipient to ensure that it is virus free and no responsibility is accepted by JPMorgan Chase Co., its subsidiaries and affiliates, as applicable, for any loss or damage arising in any way from its use. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/ catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/ --- May we not return to those scoundrels of old, the illustrious founders of superstition and fanaticism, who first took the knife from the altar to make victims of those who refused to be their disciples. - Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Re: How to redirect before some code excute
Carl Franks wrote: On 26/10/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Fayland Lam [EMAIL PROTECTED] wrote: Lee Standen wrote: It's a subroutine, right? Tried a return?such as: $c-res-redirect('http://www.yahoo.com'); return undef; Indeed I want to run the 'while' loop in backend. 'return' would not run the loop I think. Why do you want to run the loop in the background? What purpose will it serve? If we can learn your motivation, we can try to find you At Least One Way To Do It. It's not that unusual to want to send a response before doing expensive operations, so that the user doesn't have to wait. Does fork() play well with catalyst? (I've not yet had a need to try it myself) Carl Personally, rather than fork, I'd suggest some sort of message/request queue. -=Chris signature.asc Description: OpenPGP digital signature ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Re: How to redirect before some code excute
On 26/10/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Fayland Lam [EMAIL PROTECTED] wrote: Lee Standen wrote: It's a subroutine, right? Tried a return?such as: $c-res-redirect('http://www.yahoo.com'); return undef; Indeed I want to run the 'while' loop in backend. 'return' would not run the loop I think. Why do you want to run the loop in the background? What purpose will it serve? If we can learn your motivation, we can try to find you At Least One Way To Do It. It's not that unusual to want to send a response before doing expensive operations, so that the user doesn't have to wait. Does fork() play well with catalyst? (I've not yet had a need to try it myself) Carl ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Re: How to redirect before some code excute
Fayland Lam wrote: Lee Standen wrote: It's a subroutine, right? Tried a return?such as: $c-res-redirect('http://www.yahoo.com'); return undef; Indeed I want to run the 'while' loop in backend. 'return' would not run the loop I think. $c-res-redirect(...); $c-finalize_headers; while loop or whatever here might do the trick -- Matt S Trout Offering custom development, consultancy and support Technical Directorcontracts for Catalyst, DBIx::Class and BAST. Contact Shadowcat Systems Ltd. mst (at) shadowcatsystems.co.uk for more information + Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ + ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Re: How to redirect before some code excute
Ajax. Mark Christopher H. Laco wrote: Carl Franks wrote: On 26/10/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Fayland Lam [EMAIL PROTECTED] wrote: Lee Standen wrote: It's a subroutine, right? Tried a return?such as: $c-res-redirect('http://www.yahoo.com'); return undef; Indeed I want to run the 'while' loop in backend. 'return' would not run the loop I think. Why do you want to run the loop in the background? What purpose will it serve? If we can learn your motivation, we can try to find you At Least One Way To Do It. It's not that unusual to want to send a response before doing expensive operations, so that the user doesn't have to wait. Does fork() play well with catalyst? (I've not yet had a need to try it myself) Carl Personally, rather than fork, I'd suggest some sort of message/request queue. -=Chris ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/ ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Re: How to redirect before some code excute
] Carl Franks [EMAIL PROTECTED] wrote on 10/26/2006 10:15:18 AM: On 26/10/06, [EMAIL PROTECTED] [EMAIL PROTECTED] com wrote: Fayland Lam [EMAIL PROTECTED] wrote: Lee Standen wrote: It's a subroutine, right? Tried a return?such as: $c-res-redirect('http://www.yahoo.com'); return undef; Indeed I want to run the 'while' loop in backend. 'return' would not run the loop I think. Why do you want to run the loop in the background? What purpose will it serve? If we can learn your motivation, we can try to find you At Least One Way To Do It. It's not that unusual to want to send a response before doing expensive operations, so that the user doesn't have to wait. Does fork() play well with catalyst? (I've not yet had a need to tryit myself) I never have tried fork() here. I use mod_perl and it seems silly to hold a MP proc hostage for long running tasks, I usually insert a command queue into a database and have an external script (daemon) run the queue and update the status/results. This allows for very long running external commands that are not imposing on your mod_perl config, and also has the added benefit of allowing to distribute those commands across multiple machines if need be. Carl ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
[Catalyst] Re: How to redirect before some code excute
* Mark Ethan Trostler [EMAIL PROTECTED] [2006-10-26 19:00]: Christopher H. Laco wrote: Personally, rather than fork, I'd suggest some sort of message/request queue. Ajax. Some people, when confronted with a problem, think “I know, I’ll use Javascript.” Now they have two problems. (With apologies to Jamie Zawinski.) Regards, -- Aristotle Pagaltzis // http://plasmasturm.org/ ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Re: How to redirect before some code excute
How about system($cmd ) ? If the job can handle it, I tend to agree with the job-queue aproach. This can provide other forward gains like being able to distribute the work over multiple systems. --- Rodney Broom ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Re: How to redirect before some code excute
From: Jonathan Rockway [EMAIL PROTECTED] system($cmd ); I 'system(nohup ... /tmp/file )' Please, no scalar system() calls in a web application. Thanks. How come? --- Rodney Broom ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Re: How to redirect before some code excute
How come? I recommend reading perldoc perlsec. The one-argument form of Csystem invokes the system's shell to process the command (usually), leading to a number of possible security problems. Basically you're entering into the fun game of trying to escape all possible bad inputs, which is pretty close to impossible. You can do better if you use the list form: system('date', '+%s'); That will call execvp directly, meaning that quotes, slashes, etc. become meaningless. There's still a subtle security problem, though. If $ENV{PATH} happens to be some place that an attacker can write (maybe /tmp if file uploads are allowed), then a 'date' in there could be executable code or a shell script, or whatever. Anyway, you *can* invoke the shell from your app, but you're playing with fire and should be aware of the risks. -- package JAPH;use Catalyst qw/-Debug/;($;=JAPH)-config(name = do { $,.=reverse qw[Jonathan tsu rehton lre rekca Rockway][$_].[split //, ;$;]-[$_].q; ;for 1..4;$,=~s;^.;;;$,});$;-setup; ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Re: How to redirect before some code excute
Ah, injection. Yes, you're completely right. My meaning in $cmd was to say, whatever your command is Personally, I tend to only only interpret input, as apposed to using it directly. ie; $cmd_to_run = $allowed_commands{$input_cmd_menu_item} ...but now I'm OT. ;) --- Rodney Broom - Original Message - From: Jonathan Rockway [EMAIL PROTECTED] To: The elegant MVC web framework catalyst@lists.rawmode.org Sent: Thursday, October 26, 2006 13:01 Subject: Re: [Catalyst] Re: How to redirect before some code excute How come? I recommend reading perldoc perlsec. The one-argument form of Csystem invokes the system's shell to process the command (usually), leading to a number of possible security problems. Basically you're entering into the fun game of trying to escape all possible bad inputs, which is pretty close to impossible. You can do better if you use the list form: system('date', '+%s'); That will call execvp directly, meaning that quotes, slashes, etc. become meaningless. There's still a subtle security problem, though. If $ENV{PATH} happens to be some place that an attacker can write (maybe /tmp if file uploads are allowed), then a 'date' in there could be executable code or a shell script, or whatever. Anyway, you *can* invoke the shell from your app, but you're playing with fire and should be aware of the risks. -- package JAPH;use Catalyst qw/-Debug/;($;=JAPH)-config(name = do { $,.=reverse qw[Jonathan tsu rehton lre rekca Rockway][$_].[split //, ;$;]-[$_].q; ;for 1..4;$,=~s;^.;;;$,});$;-setup; ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/ ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
[Catalyst] Re: How to redirect before some code excute
Matt S Trout wrote: Fayland Lam wrote: Lee Standen wrote: It's a subroutine, right? Tried a return?such as: $c-res-redirect('http://www.yahoo.com'); return undef; Indeed I want to run the 'while' loop in backend. 'return' would not run the loop I think. $c-res-redirect(...); $c-finalize_headers; while loop or whatever here might do the trick no, it doesn't work. maybe there is something concerned with 'butter', it's not sent immediately. and I use mod_perl2, so I'd like to have a try of system. Thanks any way. ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
[Catalyst] Re: How to redirect before some code excute
Lee Standen wrote: It's a subroutine, right? Tried a return?such as: $c-res-redirect('http://www.yahoo.com'); return undef; Indeed I want to run the 'while' loop in backend. 'return' would not run the loop I think. fayland wrote: i want to redirect before the loop excute , but it seems redirect happens after the loop finish. is there any plugin or method to do this? my code . $c-res-redirect(' http://www.yahoo.com' http://www.yahoo.com%27); my $n; while($n9) { $c-log-debug($n); $n++; } $c-log-debug('as'); of course. the while loop is faked. indeed it's something involved with $c. the logic of Catalyst is run the whole sub over then call end. but I want to print redirect to visitor then run the while in backend. is that clear enough? Thanks for help. ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/ ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/