[Catalyst] Extending Catalyst -- new elements
Sir Robert Burbridge
rburbrid at cisco.com
Thu Jun 17 19:22:08 GMT 2010
Looking through the catalyst docs, it looks like trying to use the =
_create.pl script to create elements other than models, views, and =
controllers is discouraged =
(http://search.cpan.org/~bobtfish/Catalyst-Devel-1.28/lib/Catalyst/Helper.p=
m#HELPERS). =
Here's an excerpt.
All helper classes should be under one of the following namespaces.
Catalyst::Helper::Model::
Catalyst::Helper::View::
Catalyst::Helper::Controller::
I'm trying to canonize some best practices with my team at work =
(thankfully we've just decided to move from vanilla-cgi to Catalyst, =
Moose, DBIx::Class, etc.). I want to create some helpers for common =
application elements (such as forms, for example -- I'm moving us =
towards HTML::FormHandler).
I'd like our structure to be something like:
./lib/
./lib/MyApp.pm
./lib/MyApp/Model
./lib/MyApp/Model/DB.pm
./lib/MyApp/View
./lib/MyApp/View/TT.pm
./lib/MyApp/Controller
./lib/MyApp/Controller/Auth
./lib/MyApp/Controller/User
./lib/MyApp/Controller/...
./lib/MyApp/Schema/...
./lib/MyApp/Form/Auth/Login.pm
./lib/MyApp/Form/Auth/Register.pm
./lib/MyApp/Form/...
I realize that HFH says "FormHandler does not provide a custom =
controller for Catalyst because it isn't necessary. Interfacing to =
FormHandler is only a couple of lines of code" -- but I don't quite =
understand why I /wouldn't/ want one.
It makes sense to me that I would be able to create a new form this way:
script/myapp_create.pl form Auth::Login HTML::FormHandler
--has_fields=3Dusername,password,email
(or something). That would help to enforce the practice of putting form =
stuff in the MyApp::Form:: namespace. As a helper, it doesn't really =
seem to fit well with either Model, Controller, or View, so it seems as =
though it would warrant being it's own element (I'm thinking along the =
lines of Reaction or MVVM).
My questions are:
* Would this kind of functionality be better done in =
Catalyst::Helper::(Model|View|Contoller):: or somewhere else?
* Why?
* Where can I read about how to put this wherever it should go?
Thanks!
-Sir
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20100617/54829=
268/attachment.htm
More information about the Catalyst
mailing list