On Wed, 4 Jul 2007, Stephen Edmonds wrote:

> 3. When you need to (mason) cache the results of a function call and/or
> automatically supply parameters to the function based on the logged in
> user.  An actual example we have of this is a function that retrieves a
> user's library information from a remote (to us) database.  The result
> of this function is used in a number of places at varying levels of
> detail, but they all call the same component to get the raw data.  We
> can trust that the caching will prevent excessive hits to the remote
> database and that all places will use the same cached data.

This is also something I'd stick in a module. It sounds like it belongs in 
a User class, for example, and the user class could know to cache this 
value.

With Catalyst, you can also do caching in the controller, and for the 
project I'm working on, I just moved some caching out of a Mason 
component, into the controller. This worked well.

> 4. When you have what should be a function except that it is operating
> directly on user input.  In a couple of applications we have a
> validate_input.comp that uses $m->request_args() to get the user input
> and then validate and/or manipulate it.  At the end it returns a hashref
> of the data and an arrayref of errors.  We do it this was as we consider
> processing the raw user input to be the responsibility of the interface,
> and all of the interface code is in mason.  It could be argued that
> there could be a validate_input() function that is given
> $m->request_args() by the interface...

This _definitely_ belongs in controller code, and even before I started 
using Catalyst I was trying to move this stuff out of Mason components, 
using MasonX::WebApp.


-dave

/*===================================================
VegGuide.Org                        www.BookIRead.com
Your guide to all that's veg.       My book blog
===================================================*/

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Mason-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to