Because the attachment was stripped here's the text:
-----------------------------------------------------
use SAWA::Machine;
sub init {
my $self = shift;
my %config = (
SawaContext => sub { $self->sawa_context(@_) },
SawaResetPipe => sub { $self->reset_sawa_pipeline(@_) },
SawaAddPipe => sub { $self->sawa_pipeline(@_) },
XSLT_Style => sub { $self->stylesheet(@_) },
);
while (my ($name, $sub) = (each %config)) {
$self->register_config($name => $sub);
}
}
sub stylesheet {
my ( $self, $conf ) = ( shift, shift );
$conf ||= $self->config;
my $key = $self->plugin_name . '::stylesheet';
@_ and $conf->notes( $key, [EMAIL PROTECTED] );
return $conf->notes($key);
}
sub sawa_context {
my ($self, $conf) = (shift, shift);
$conf ||= $self->config;
my $key = $self->plugin_name.'::sawa_context';
$_[0] and $conf->notes($key, $_[0]);
return $conf->notes($key);
}
sub reset_sawa_pipeline {
my ($self, $config) = @_;
$config ||= $self->config;
my $key = $self->plugin_name . '::sawa_pipeline';
$config->notes($key, []);
return $config->notes($key);
}
sub sawa_pipeline {
my ( $self, $config ) = ( shift, shift );
$config ||= $self->config;
my $key = $self->plugin_name . '::sawa_pipeline';
my $pipe = $config->notes($key);
push @$pipe, @_;
$config->notes( $key, $pipe );
die "SAWA Pipeline is Empty!!" unless $pipe;
return $pipe;
}
sub setup_fake_apache_request {
my ( $self, $hd ) = @_;
# This is horrible, I think SAWA needs to be patch to trust DUCK-
typing instead
@Apache::Request::ISA = qw(AxKit2::HTTPHeaders);
*Apache::Request::print = sub { $self->client->write( @_[ 1 ..
$#_ ] ) };
*Apache::Request::cgi_header_out = sub { };
*Apache::Request::send_http_header = sub { $self->client-
>send_http_headers };
bless $hd => 'Apache::Request';
return $hd;
}
sub run_sawa {
my ( $self, $hd ) = @_;
$self->client->watch_read(0);
my $app = SAWA::Machine->new();
$app->axkit_plugin($self);
$app->query($hd);
$app->pipeline( @{ $self->sawa_pipeline() } );
$app->run( $self->sawa_context() );
}
sub hook_xmlresponse {
my ( $self, $input ) = @_;
return DECLINED unless $self->stylesheet( $self->config );
my $hd = $self->setup_fake_apache_request( $self->client-
>headers_in );
# we need a new way of dealing with SAWA
*Apache::Request::print = sub {
my $self = shift;
my $xml = ref $_[0] eq 'XML::LibXML::Document'? $_[0] : join
('', @_);
$input->dom($xml);
};
$self->run_sawa( $hd, @_ );
my $stylefile = $self->stylesheet( $self->config );
my $out = $input->transform( map XSLT($_), @$stylefile );
return OK, $out;
}
sub hook_response {
my $self = shift;
my $hd = $self->setup_fake_apache_request(shift);
$self->run_sawa( $hd, @_ );
return OK;
}
__END__
=pod
<Location /sawa>
DocumentRoot demo/sawa
Plugin demo/sawa
SawaAddPipe SAWA::Test
SawaAddPipe SAWA::Output::Scalar
XSLT_Style demo/sawa/xslt/default.xsl
</Location>
=cut
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]