[Dbix-class] Molesting Schemas

Christopher H. Laco claco at chrislaco.com
Tue Jun 6 17:30:42 CEST 2006


Matt S Trout wrote:
> 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.
> 
> 

This works, but it appears to cause quite the performance issue when
calling load_components() on the new classes. The performance issue
appears to go away if I call load_components either before
compose_namespace, or on the schema class, and not on a connected schema
object.

Is there a better way to get at entires rows before update/insert calls,
other than loading components into the result sources?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: OpenPGP digital signature
Url : http://lists.rawmode.org/pipermail/dbix-class/attachments/20060606/2023ccaa/attachment.pgp 


More information about the Dbix-class mailing list