[Catalyst]
Catalyst::Plugin::XMLRPC/Catalyst::Component::ACCEPT_CONTEXT issue.
kevin montuori
montuori at gmail.com
Sat Nov 1 20:14:02 GMT 2008
hi all -- i have a trivial catalyst (version 5.7015) application using
the XMLRPC plugin (version 1.0) with two controllers
lib/MyApp/Controller/API.pm
lib/MyApp/Controller/API/SubGroup.pm
and one mixin class
lib/MyApp/ControllerBase/Quux.pm
which uses the base class Catalyst::Component::ACCEPT_CONTEXT (version
0.05) and has one method:
sub fancy {
my $self = shift;
my $c = $self->context;
print STDERR "context is: $c, ", (ref $c ? ref $c : "(not blessed)"), "\n";
}
when i call this method from MyApp::Controller::API::test i see that $c
is a blessed MyApp object; when i call the same method from
MyApp::Controller::API::SubGroup::test the value of $c is the string
"MyApp" and is not blessed. i'd have thought that the behavior would be
the same in both cases.
my question is: is my expectation incorrect and this is the correct
behavior or is there a bug somewhere?
i've included the three modules and MyApp.pm below, everything else in
the project is untouched. thanks for any help!
cheers.
k.
--
kevin montuori
montuori at gmail.com
##################################################
#
# lib/MyApp.pm
#
package MyApp;
use strict;
use warnings;
use Catalyst::Runtime '5.70';
use Catalyst qw/-Debug ConfigLoader Static::Simple XMLRPC/;
our $VERSION = '0.01';
__PACKAGE__->config( name => 'MyApp' );
__PACKAGE__->setup;
1;
##################################################
#
# lib/MyApp/ControllerBase/Quux.pm
#
package MyApp::ControllerBase::Quux;
use strict;
use base qw[ Catalyst::Component::ACCEPT_CONTEXT ];
sub fancy {
my $self = shift;
my $c = $self->context;
print STDERR "context is: $c, ", (ref $c ? ref $c : "(not blessed)"), "\n";
}
1;
##################################################
#
# lib/MyApp/Controller/API.pm
#
package MyApp::Controller::API;
use strict;
use base qw[ Catalyst::Controller
MyApp::ControllerBase::Quux ];
sub default : Private {
my ($self, $c) = @_;
$c->xmlrpc;
}
sub test : XMLRPC {
my ($self, $c) = @_;
$self->fancy;
return "Test Succeeded.";
}
1;
##################################################
#
# lib/MyApp/Controller/API/SubGroup.pm
#
package MyApp::Controller::API::SubGroup;
use strict;
use base qw[ MyApp::Controller::API ];
sub test : XMLRPC {
my ($self, $c) = @_;
$self->fancy;
return "Test Succeeded";
}
1;
More information about the Catalyst
mailing list