[Catalyst] A suitable method to redraw a page

Dermot paikkos at googlemail.com
Tue Sep 23 11:53:05 BST 2008


Hi,

I have a controller who's job is to copy some files (4-6). These files
can be quite big and the time it takes has been causing what looks
like timeouts on the server.

[Tue Sep 23 09:48:55 2008] [error] [client x.x.x.x] FastCGI: comm with
server "/var/www/MyApp/script/motion_fastcgi.pl" aborted: idle timeout
(30 sec), referer: http://somehost/cgi-bin/doit.cgi
[Tue Sep 23 09:48:55 2008] [error] [client x.x.x.x] FastCGI:
incomplete headers (0 bytes) received from server
"/var/www/MyApp/script/myapp_fastcgi.pl"

I could increase the timeout period on the httpd daemon. I thought a
more elegant solution would be to present a page with the results for
each file after it's copied that is updated with the status of each
copied file. So the same window refreshes and the next file is listed
with the copy status.

I have achieved this in the past (CGI) by putting a form on the page
and using javascript/onload/submit while items < 1. It's a bit of a
hack but it works.

Is there a method within Catalyst that might help me reach my goal?
Something akin to Chained perhaps.

Alternatively can I loop through the list of files and $c->{template}
= 'files/rename.tt2'. My experiments haven't been successful. I get
the whole page of results. Is there something like $c->forward that I
should be using here?

Here an abridged versions of the controller.

sub rename : Local {
   my ($self, $c) = @_;
   die if ($c->request->param('id') !~ /\d+/);

   my $list = getFilesBySubID($c, $c->request->param('id'));
   my @moved;

   foreach my $file ( @{$list} ) {
        my $source = $file->path;
        my $type = getFileTypeFromName(basename($file->path));
        my %state = (
                   'id'         => $c->request->param('id'),
                   'source'     => $file->path,
                   'distin'     => undef,
                );
                my $path =
getPathFromNumber($c->request->param('splnumber'), $type);
                my $x = copy($source,$path) or warn "Cannot copy
$source to $path: $!\n";
                $state{'success'} = $x;
                $state{'distin'} = $path;
        }
        else {
                $state{'success'} = 0;
        }
        push(@moved, \%state);
        $c->stash->{moved} = [@moved];
        $c->stash->{template} = 'files/rename.tt2';
   }
}

I hope this makes sense :-/. Any advice would be appreciated.
Thanx,
Dp.



More information about the Catalyst mailing list