[Catalyst-dev] Plugin or controller?
Kiki
kiki at bsdro.org
Tue Jun 2 09:48:51 GMT 2009
Matthias Dietrich wrote:
> Don't get me wrong, I don't want to create this as a plugin under all
> circumstances. I just want to figure out when a module is a plugin,
> when a model and when a controller. But I'm getting closer to the
> truth ;).
>
> matt
Disclaimer: IANACD (Core Developer) but here's my take.
A plugin changes fundamental functionality. By fundamental I mean mostly
the request dispatch. For example C::P::Static skips the whole dispatch
process, it just serves static files when the path prefix matches. And,
as pointed out before, C::P::Authorization::* also alters the dispatch
if the authz conditions are not matched. A plugin is loaded in the main
app module (lib/MyApp.pm).
A controller base adds functionality. C::C::HTML::FormFu allows you to
extend one or more of your controllers with HTML::FormFu functionality
(displaying, processing and validating forms). C::C::RequestToken
extends your controllers with token generating functionality. A
controller base class is mostly used as a parent/base to the actual
controller class and usually provides new methods to $self.
Finally, a model provides data. Be it from a database, XML feed,
(XML)RPC, etc. it will supply data on demand. A model is accessed
explicitly by: $c->model('MyModel'). A model's data source can (and
sometimes will) be used outside the web framework too (from a command
line script, cron job, etc.)
HTH
More information about the Catalyst-dev
mailing list