Hey Andy, and general Catalyst guys.
Attached is a patch to convert Catalyst::Plugin::UploadProgress into using Moose::Role instead of NEXT, since the latter is deprecated as of Cat-Runtime .18.

Could you have a look over it? I'm not 100% sure the first function is "good" since it's never calling super() from inside prepare_body_chunk. But hey, that's just how the original code worked too..

Cheers,
Toby
>From 95e1d77a555dcc1caae2ab29cbbd843450e8e337 Mon Sep 17 00:00:00 2001
From: Toby Corkindale <[email protected]>
Date: Thu, 21 Jan 2010 15:59:03 +1100
Subject: [PATCH] Remove NEXT, replace with Moose::Role

---
 lib/Catalyst/Plugin/UploadProgress.pm |   32 +++++++++++++++++---------------
 1 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/lib/Catalyst/Plugin/UploadProgress.pm b/lib/Catalyst/Plugin/UploadProgress.pm
index ee97eb3..c0910f3 100644
--- a/lib/Catalyst/Plugin/UploadProgress.pm
+++ b/lib/Catalyst/Plugin/UploadProgress.pm
@@ -2,11 +2,12 @@ package Catalyst::Plugin::UploadProgress;
 
 use strict;
 use warnings;
-use NEXT;
+use Moose::Role;
 
-our $VERSION = '0.04';
+our $VERSION = '0.10';
 
-sub prepare_body_chunk {
+# I'm concerned that this doesn't call super() at all..
+override 'prepare_body_chunk' => sub {
     my ( $c, $chunk ) = @_;
     
     my $body = $c->request->{_body};
@@ -33,9 +34,9 @@ sub prepare_body_chunk {
             $c->cache->set( 'upload_progress_' . $id, $progress );
         }
     }
-}
+};
 
-sub prepare_body {
+override 'prepare_body' => sub {
     my $c = shift;
     
     # Detect if the user stopped the upload, prepare_body will die with an invalid
@@ -49,7 +50,7 @@ sub prepare_body {
             $croaked = shift;
         };
         
-        $c->NEXT::prepare_body(@_);
+        super;
     }
     
     if ( $croaked ) {
@@ -67,9 +68,9 @@ sub prepare_body {
         # rethrow the error
         Catalyst::Exception->throw( $croaked );
     }
-}
+};
 
-sub dispatch {
+override 'dispatch' => sub {
     my $c = shift;
     
     # if the URI query string is ?progress_id=<id> intercept the request
@@ -79,20 +80,18 @@ sub dispatch {
         return $c->upload_progress_output( $1 );
     }
     
-    return $c->NEXT::ACTUAL::dispatch(@_);
-}
+    return super;
+};
 
-sub setup {
+after 'setup' => sub {
     my $c = shift;
             
-    $c->NEXT::setup(@_);
-    
     unless ( $c->can('cache') ) {
         Catalyst::Exception->throw(
             message => 'UploadProgress requires a cache plugin.'
         );
     }
-}
+};
 
 sub upload_progress {
     my ( $c, $upload_id ) = @_;
@@ -279,6 +278,9 @@ JSON output from C</upload_progress_output>.
 
 Andy Grundman, <[email protected]>
 
+NEXT to Moose::Role conversion by Toby Corkindale, <[email protected]>, blame him
+for any faults there..
+
 =head1 THANKS
 
 The authors of L<Apache2::UploadProgress>, for the progress.js and
@@ -292,4 +294,4 @@ progress.css code:
 This program is free software, you can redistribute it and/or modify it under
 the same terms as Perl itself.
 
-=cut
\ No newline at end of file
+=cut
-- 
1.6.6

_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to