[Catalyst] C::M::{CDBI,DBIC} vs direct Loader use?

Perrin Harkins perrin at elem.com
Thu Nov 17 06:07:22 CET 2005


Brandon Black wrote:
> If a Model has data items which are text strings that may contain
> HTML-illegal characters like '&', and it's not proper to inflate() all
> your strings with html-escapes like '&' in your data Model - when
> else could it ever get automagically done without having to wrap every
> use of a string in your Views with a helper wrapper function to escape
> them?

It can't ever get automagically done.  Some things are not supposed to 
be HTML-escaped.  You could make it default to escaping everything and 
then turn it off for certain things, but ultimately you still have to 
make this decision for each piece of data if you want to get it right.

> I'm almost inclined to say that the general solution is to have a
> Catalyst/Web/HTML/etc-independant data Model that doesn't do such
> transforms, and subclass it for use as a Catalyst data Model where you
> insert such transforms and perhaps even depend on current request
> context.

That's a really bad place to do HTML-escaping.  What if you want to make 
a little command-line tool that uses a model class?  This kind of stuff 
is 100% view.  You can do something hacky if it's sufficient for your 
project, but you are giving up the separation that MVC was supposed to 
give you.

- Perrin



More information about the Catalyst mailing list