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

Jules Bean jules at jellybean.co.uk
Wed Nov 16 09:05:38 CET 2005


Brandon Black wrote:
> As near as I can tell so far (and I'm still pretty new at this whole
> thing), the only difference is that the Catalyst:: route uses the
> Catalyst "->config" construct, so your model config parameters could
> presumably automagically come from your application-wide YAML config
> file or what-have-you.  Otherwise the approaches seem identical in
> their net results once you get past minor syntactical differences at
> class initialization time.  I originally figured that deriving via
> Catalyst::... must give some access to the $c context within the
> database classes, but that doesn't seem to be the case (the only way
> I've found to get that is via Catalyst::Plugin::Singleton).
>   

I think that's more or less accurate. You are of course free to add 
methods to your model classes and pass in $c to them if you want to.
> Am I missing something here, or does that about sum it up?  And would
> using Singleton context access from within a method of a table within
> a model be considered bad form? (This is back on that problem of
> getting automatic timestamp column inflation/deflation to pay
> attention to timezone settings for the current application
> user/session).
>
> Any insight appreciated :)
>   

I can't give you insight so much as opinion. Yes, I think Singleton is 
bad form, as a rule. I wouldn't do it that way. In terms of your 
specific problem, my MVC hunch is that in the model you should keeps 
times in some standard form (UTC, for example) and that it is the job of 
the View to format a time according to the user's timezone.

Jules



More information about the Catalyst mailing list