--- trunk/lib/Frey/Pipe.pm 2008/11/25 00:26:15 507 +++ trunk/lib/Frey/Pipe.pm 2009/01/06 23:44:59 953 @@ -1,8 +1,9 @@ package Frey::Pipe; use Moose; -extends 'Frey::ClassLoader'; +extends 'Frey::Class::Loader'; with 'Frey::Web'; +use lib 'lib'; use Frey::Action; =head1 DESCRIPTION @@ -27,6 +28,8 @@ default => 'Frey::Feed/as_data+uri=http://blog.rot13.org/index.xml|Frey::View::Dumper/as_markup', ); +sub render_pipe { 'radio' }; + use Data::Dump qw/dump/; sub as_markup { @@ -43,7 +46,6 @@ warn "# part: '$part'"; if ( $part =~ m{^([^/]+)/([^\+\?]+)(.*)?$} ) { my ( $class, $method, $args ) = ( $1, $2, $3 ); - push @parts, { $class => { method => $method, args => $args } }; my $params = $pipe; $params = {} unless defined $params; if ( defined $args ) { @@ -52,7 +54,7 @@ map { my ( $name, $value ) = ( $1, $2 ) if m{^([^=]+)=(.+)$} || confess "can't parse '$_'"; $params->{$name} = $value; - } split(/\s*\+\s/, $args) + } split(/[;&]/, $args) } my ( $html, $default ) = Frey::Action->new( class => $class, params => $params )->params_form; @@ -60,21 +62,47 @@ warn "# pipe $part" if $self->debug; my $o = $self->new_frey_class( $class, $default ); + + # XXX copy depends from parts of pipe + if ( $o->can('depends') ) { + $o->depends; + my $current_head; + $current_head->{$_}++ foreach $self->head; + foreach ( $o->head ) { + next if $current_head->{$_}++; + $self->add_head( $_ ); + } + } + my $result = $o->$method; warn "# result ",length( $result ), " bytes ", ref($result); + my $current_status; + $current_status->{$_}++ foreach $self->status; + foreach ( $o->status ) { + next if $current_status->{$_}++; + $self->add_status( $_ ); + warn "# pipe add_status: $_"; + } + $self->content_type( $o->content_type ) if $o->can('content_type'); $out = $result; $method =~ s{^as_}{}; $pipe = { $method => $result }; + push @parts, { $class . '->' . $method => $result }; } else { die "don't know what to do with '$part' from ",$self->pipe; } } - warn "# pipe ", $self->title, " parts ",dump( @parts ); - $self->add_status( $_ ) foreach @parts; + $pipe = $self->pipe; + + $out = $self->error( + qq|$pipe = $out not scalar\n| + . $self->html_dump($out) + ) if ref $out; + return $out; }