[Catalyst] how to reuse Catalyst Schema for non-web purposes?

Matthias Dietrich mdietrich at cpan.org
Thu Apr 23 10:10:49 GMT 2009


Hi,

this is an interesting topic.  I'm also one of that guys that put  
business logic into the controllers, but I never released any project  
yet, so it's my "test Catalyst" period and I'm still learning :) (and  
I never used MVC before).

I had that problem to use data of the db outside of the web app from a  
perl script.  What I have done so far is to use  
Catalyst::Plugin::CommandLine and accessed the model (that contains no  
business logic, the scripts actions differ from those of the web  
app).  That was fine for me in that situation.

Now, if I want to use business logic - which is implemented in  
Catalyst - in my script, I would get stuck.  Where should I place the  
business logic that I want to use on both ends?  In the controller  
actions?  No way, I don't want to call the action that is called  
though the web browser - because I might have some more logic that  
should be executed only when coming over the web.  (I asked a similar  
question to me very often yet: where to put business logic that is  
used by controller action A *and* B?)

There may be the possibility to add a new function to the namespace of  
one of the Controllers, but that sounds ugly to me.

So it's the model I put the business logic in?  That sounds ok, for  
now.  But what about this:
  * Input from the web has to be validated.  May be I use  
Data::FormValidator, may be FormFu.  However, I may have to validate  
the params I get from the script (eg. data import from ERP systems),  
too.  Do I have to implement the validation again?  And maybe  
normalization/converting, too?  Or where would you place these  
functionality?  Extra modules?
  * What about business logic that is in not only bound to a specific  
schema but has an overall logic that fetches data from different  
tables, adds some somewhere and produces results?  How would you  
implement such a logic?  Any examples?
  * An example for using data and logic outside of the web app would  
be generating invoices by night.  That process would bring out some  
PDFs which will be printed or sent by mail through another script.   
Shouldn't a view be involved in this process that builds the PDFs from  
templates?  Is it possible to build this example upon a Catalyst web  
app?  Examples?

Thanks for listening, looking forward to the answers...

Matt

-- 
rainboxx Matthias Dietrich
Freier Software Engineer

rainboxx                  |  Tel.: +49 (0) 151 / 50 60 78 64
Tölzer Str. 19            |  Mail: matt at rainboxx.de
70372 Stuttgart           |  WWW : http://www.rainboxx.de

XING: https://www.xing.com/profile/Matthias_Dietrich18
GULP: http://www.gulp.de/profil/rainboxx.html

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 194 bytes
Desc: Signierter Teil der Nachricht
Url : http://lists.scsys.co.uk/pipermail/catalyst/attachments/20090423/085de2b4/PGP.pgp


More information about the Catalyst mailing list