[Dbix-class] Re: looking for code suggestion

Matt S Trout dbix-class at trout.me.uk
Tue Jan 29 09:27:36 GMT 2008


On Tue, Jan 29, 2008 at 10:18:57AM +0800, Fayland Lam wrote:
> Matt S Trout wrote:
> >On Mon, Jan 28, 2008 at 10:43:42AM +0800, Fayland Lam wrote:
> >>hmm, basically I'd like to use cache and others in Schema. so I package 
> >>my own Foorum::Schema like this:
> >>
> >>http://foorum.googlecode.com/svn/trunk/lib/Foorum/Schema.pm
> >>
> >>use Foorum::XUtils ();
> >>
> >>sub base_path {
> >>   return Foorum::XUtils::base_path();
> >>}
> >>sub config {
> >>   return Foorum::XUtils::config();
> >>}
> >>sub cache {
> >>   return Foorum::XUtils::cache();
> >>}
> >>
> >>
> >>so that in ResultSet or pl.
> >>
> >>we can use $schema->cache() to get the cache object. or 
> >>$self->schema->cache() in ResultSet pm.
> >>
> >>I'm wondering if it's the correct way to do it?
> >
> >Given we have no idea what Foorum::XUtils is, "no idea".
> >
> >Personally I'd be a bit wary of anything that starts making per-schema
> >things global though ...
> 
> 
> 
> well, I'd like to ask how to use Template or Cache::Cache in your 
> ResultSet modules?

If it's schema-global, add an attribute to the schema class and set it just
like any other attribute.

This stuff is, after all, just objects. Treat it as such.

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director                    http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/            http://www.shadowcat.co.uk/servers/



More information about the DBIx-Class mailing list