[Catalyst] New Bundle::Catalyst
Brandon Black
blblack at gmail.com
Thu Nov 17 06:16:56 CET 2005
On 11/16/05, Matt S Trout <dbix-class at trout.me.uk> wrote:
> On Wed, Nov 16, 2005 at 12:16:32AM -0600, Brandon Black wrote:
> > As alluded to in a seperate post I just made a little while ago, since
> > that post you responded to, the least hackish way I've found to do it
> > so far is to use Catalyst::Singleton and reference
> > MyApp->context->session->{timezone} directly in the inflate/deflate
> > code back at Model initialization time. I'm just not really clear on
> > whether Singleton was meant to be used from a Model like that, whether
> > it's a good idea at all, or whether there might be an ever better way
> > to go about this.
>
> how about
>
> local MyApp::M::DBIC->config->{timezone} = $c->session->{timezone};
> <DBIC table class calls here>
>
Now that is really interesting. I have my own custom Session plugin
for this app anyways that knows about things like the fact that my
users' sessions have a timezone at all, so I could also just set that
config entry directly from my Session plugin (without "local") back
when the session is detected and the usual session data is populated,
and it will be always valid for the current session (or defaulted in
the case of no valid session).
It eliminates Singleton, and it can be fixed in one place in one file
and left alone everywhere else, and doesn't seem to horribly violate
any rules or norms of this whole OO / MVC philosophy (unless X->config
is supposed to be considered a static thing that is only written to at
app start time).
-- Brandon
More information about the Catalyst
mailing list