[Catalyst] Plugin methods and context namespace

John Wang johncwang at gmail.com
Fri Nov 25 05:00:14 CET 2005


On 11/24/05, Sebastian Riedel <sri at oook.de> wrote:
>
> Am 25.11.2005 um 02:22 schrieb John Wang:
>
> > 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.
> >
> > MyApp->plugin( 'prototype', 'HTML::Prototype' );
> >
> > What if the plugin methods need the $c context object like a
> > Catalyst::Plugin?
>
> Then it should be a Catalyst::Plugin imo.


I started with a Catalyst::Plugin but I wanted the plugin methods to be like
$c->myplugin->foo instead of $c->foo. Can this be done in a recommended way
while also using $c in the plugin methods?

The goal is a generic plugin that handles email-based account activation and
password reset including creating/emailing/verifying activation and password
reset codes. It would be nice to make this a plugin instead of a controller
since I'd like to use it in other apps. It would also be nice to use $c
context to access Email, Session, Subrequest, and View plugins. Right now
I'm using subrequest to generate the body of the emails using templates and
need to put an empty routine in a Controller for subrequest to call (i.e.
sub render : Local {} ) ... which is okay. The above be done using a
Catalyst::Plugin but my question now is I'd like the methods to be in the
$c->myplugin->foo format which I'm not sure can be done in a recommended
manner.

I think a plugin that handles email-based account activation and password
resets could be generally useful but I'm not sure how to do one cleanly (i.e.
$c->myplugin->foo method formats and using the templating engine without
needing an empty Controller routine in the dispatcher).

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


More information about the Catalyst mailing list