[Catalyst] How to execute controller at startup
Jonathan T. Rockway
jon at jrock.us
Tue Aug 7 19:03:04 GMT 2007
> On Mon, Aug 06, 2007 at 11:33:04PM -0700, Aditya Verma wrote:
> > Hi All,
> >
> > Thank you very much for all your valuable comments at appreciate your quick
> > response.
> >
> > I have one more query.
> > I have implemented a Plugin. How can I call a plugin method from controller
> > outside of the controller methods.
> You shouldn't.
>
> If you need to do that, the method shouldn't be in a plugin.
>
> Don't hack up your Catalyst app, fix your design :)
Expanding on what mst said, keep in mind that plugins are reserved for
things that need to affect the request cycle. If you just need some
functionality, write a regular module. If it needs $c, pass in $c.
Component base classes are also possible, and are a better approach
than plugins. (See C::Plugin::FormBuilder
vs. C::Controller::FormBuilder. Both are on CPAN so you can compare
the approaches.)
Finally, phaylon's Extending Catalyst guide:
http://search.cpan.org/~jrockway/Catalyst-Manual-5.700701/lib/Catalyst/Manual/ExtendingCatalyst.pod
> > suppose i have a Plugin named "Catalyst::Plugin::MyPlugin" contains a method
> > called "sub myFunc {}"
>
> That should be my_func, not myFunc. This is perl, not java. Please stick to
> the correct naming conventions for things.
TMTOWTDI, but your way is rather unconventional. Identifiers should
be lowercase (%karma_for), constants should be uppercase
($SECRET_OF_THE_UNIVERSE), and modules should be CamelCase
(MyApp::SomeThing). Anything else will make people like mst mad
because it's really really ugly.
Hope this helps.
Regards,
Jonathan Rockway
More information about the Catalyst
mailing list