[Dbix-class] Molesting Schemas

Matt S Trout dbix-class at trout.me.uk
Mon Jun 5 18:58:07 CEST 2006


Christopher H. Laco wrote:
> As part of the new Handel stuff, I'm trying to provide as much ability
> as possible of using an existing schema instead of just relying on the
> default Handel schema.
> 
> As part of this process, I'm 'injecting' custom component classes into
> the specified schema using load_components. Currently, this operates on
> the classes themselves using $schema_class->class($cart_class).
> 
> The evil in this is that fact that once I inject Handel components into
> the schema classes, they will effect the use of the schema outside of
> Handel. This is somewhat of a Bad Thing.
> 
> So, my question is two fold: First, is it possible to load_component a
> new component into a source instance only, not its class, in a way that
> it will only effect the current source/schema instance, and not all
> usages of the source class?
> 
> $schema_instance->source($cart_source)->load_components(qw/Foo/)
> 
> where
> 
> $schema_instance->class($cart_class) does not have "Foo" loaded?

No, because this happens at the class level.

OTOH you *could* quite happily take the user schema, compose_namespace 
it to somewhere else (like e.g. Catalyst::Model::DBIC::Schema does) and 
then inject stuff into the classes in the composed version, which will 
have no effect whatsoever on the originals.



More information about the Dbix-class mailing list