[Catalyst] Plugin methods and context namespace

John Wang johncwang at gmail.com
Fri Nov 25 02:22:29 CET 2005


On 11/24/05, Sebastian Riedel <sri at oook.de> wrote:
>
> Am 24.11.2005 um 23:36 schrieb John Wang:
>
> > To keep the $c context namespace cleaner, I'd like to add plugin
> > methods like $c->myplugin->foo instead of $c->foo.
> > [...]
> > sets $c->myplugin( MyPlugin->new( $c ) ) in prepare
> > [...]
>
> MyApp->plugin( 'prototype', 'HTML::Prototype' );
>
> $c->prototype->define_javascript_functions;


What if the plugin methods need the $c context object like a
Catalyst::Plugin? Will that automagically call a "new" subroutine? If so,
can a parameter list be passed in, say:

MyApp->plugin( 'myplugin', 'MyPlugin', [$c] );

I can retrieve the context object using C::P::Singleton but I'd rather not
hardcode MyApp into a plugin. Another option may be to subsequently set the
context like:

$c->myplugin->context( $c );

Is there a preferred way?

John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rawmode.org/pipermail/catalyst/attachments/20051124/7d792d34/attachment-0001.htm


More information about the Catalyst mailing list