[Catalyst] Best practice: How to build app parts reusable?

Zbigniew Lukasiak zzbbyy at gmail.com
Tue Jun 2 09:05:54 GMT 2009


On Sun, May 31, 2009 at 6:06 PM, Matthias Dietrich <mdietrich at cpan.org> wrote:
> Hi,
>
> in one of my Catalyst apps I'm building application parts that I want to
> reuse in other Catalyst apps where possible.  What's the best practice to do
> that?  I mean the complete parts from controller, to model, DBIC schema
> classes and templates.
>
> Let's assume one part is a guestbook (no, it's not but it's a funny example
> ;)).  The integration of the controller class is very easy.  I just would
> build a new controller inside the app which uses the guestbook controller as
> base class and sets the correct namespace, where the guestbook should
> appear.  A similar procedure would get me the model and schemes into my app,
> but it requires a wrapper class for each class the guestbook brings with.
>  And the templates?  The only way I know of is to copy and paste them into
> the 'root' folder of the app.

Just one idea - in the TT view there is a
http://search.cpan.org/~mramberg/Catalyst-View-TT-0.29/lib/Catalyst/View/TT.pm#DYNAMIC_INCLUDE_PATH
option.  I have never eventually used that - but when I was adding it
what I had in mind was something like template inheritance.  By
splitting the templates into separate files you can use it to override
those individual templates just like you can override methods in a
class.  The difference is that a class is a file and method is a part
of that file - here the the corresponding things are a directory and
an individual template.

>
> There has to be a better way.  But which?
>
> I'm also thinking about whole reusable applications.  For example a shopping
> system which can be extended and modified by overwriting methods while the
> base system can be upgraded seamlessly.  (I know MojoMojo as a standalone
> Catalyst app, but it's only standalone and not to be extended locally.)

There is Handel - I have never explored it but I think the design goal
was to make it extendable.


-- 
Zbigniew Lukasiak
http://brudnopis.blogspot.com/
http://perlalchemy.blogspot.com/



More information about the Catalyst mailing list