[Catalyst] ACCEPT_CONTEXT with Module::Pluggable::Object

Tomas Doran bobtfish at bobtfish.net
Wed Oct 5 17:47:27 GMT 2011


On 5 Oct 2011, at 15:42, Cylon Toaster wrote:

> Hello,
>
> in the book 'Guide to Catalyst' is described how to build a Driver  
> Model using Module::Pluggable::Object.
> You can find it on page 88, chapter 'A Driver Model for Generic  
> Translation'.
>
> All works fine :-)
>
> But now I wanted to implement ACCEPT_CONTEXT, which always worked  
> fine in 'normal' Models.
> But when using 'Module::Pluggable::Object' and  
> 'Class::MOP::load_class' the ACCEPT_CONTEXT-method is not invoked.
>

ACCEPT_CONTEXT is a Catalyst model initialization feature, not a  
general perl feature.

Inside model code, nothing will call anything on modules you load  
yourself.. So when you call $some_class->new, then you're just calling  
$some_class->new, and you need to take care of it yourself if you want  
to pass $c down. (Although passing $c down is a bad idea, as your  
modules are then entirely aware of and tied to Catalyst - it'd be  
better to extract the things you need and pass them individually).

Cheers
t0m





More information about the Catalyst mailing list