[Catalyst] New Bundle::Catalyst

Matt S Trout dbix-class at trout.me.uk
Wed Nov 16 14:17:54 CET 2005


On Wed, Nov 16, 2005 at 12:16:32AM -0600, Brandon Black wrote:
> On 11/15/05, Bill Moseley <moseley at hank.org> wrote:
> > Another ugly hack you might be able to do is at the start of your
> > request you replace the inflate sub in your classes.
> >
> > Untested and maybe way off, but a wild guess might be:
> >
> >
> >     Class->meta_info('has_a', $method )->args->{inflate} = sub {
> >         my $dt = DateTime::Format::Pg->parse_datetime( shift );
> >         $dt->set_time_zone( $c->session->{timezone} );
> >         return $dt;
> >     };
> >
> >
> 
> That's certainly interesting - I hadn't considered that angle before. 
> It's promising, but I think someone else working on my project down
> the road may come find me and shoot me for doing that when they see it
> :)

Similar for DBIC would be $class->column_info($col)->{_inflate_info}{inflate}

(though column_info only exists in trunk currently)
 
> 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>

?

-- 
     Matt S Trout       Specialists in Perl consulting, web development, and
  Technical Director    UNIX/Linux systems architecture and automation. Mail
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

 + Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +



More information about the Catalyst mailing list