[Dbix-class] [Patch] PK::Auto documentation

James FitzGibbon jfitzgibbon at primustel.ca
Fri Dec 16 15:43:09 CET 2005


A question about that: when you say "loaded before", it gives the impression
to me that you mean:

__PACKAGE__->load_components( qw|PK::Auto::Foo Core DB| );

or

__PACKAGE__->load_components( 'PK::Auto::Foo' );
__PACKAGE__->load_components( qw|Core DB| );

But I have found that calling:

__PACKAGE__->load_components( qw|Core DB| );

at compile time and then calling:

__PACKAGE__->load_components( 'PK::Auto::Foo' );

at runtime works.  I need to do this because I have a single base DBIC
subclass that needs the methods from Core and DB at compile time, then needs
to examine the DSN at runtime to extract the DBD and perform DBD-specific
init code (in this case, PK::Auto::Oracle or PK::Auto::Pg):

   66     # DBD-specific initialization
   67     my $dbd = (split(/:/, lc $_[0]))[1];
   68     if( 'oracle' eq $dbd ) {
   69         __PACKAGE__->init_oracle;
   70     }
   71     elsif( 'pg' eq $dbd ) {
   72         __PACKAGE__->init_postgresql;
   73     }
   74     else {
   75         LOGWARN("don't know how to handle dbd '$dbd'!");
   76     }
   77
   78     # set DB connection info
   79     __PACKAGE__->connection( @_, { AutoCommit => 0 } );

This works just fine, because DBIx::Class::Componentized::_inject_base
unshifts it's args onto @ISA.  I'm not sure if that is something that only
works since the C3 MRO code was added or not.

I would suggest that a better way to describe the requirements of PK::Auto
and others like it is:

- if it is loaded at the same time as Core, it must be to the left in the
list of args passed to ->load_components

- if it is not loaded at the same time, it must be loaded after Core

Does that make sense?

-----Original Message-----
From: dbix-class-bounces at lists.rawmode.org
[mailto:dbix-class-bounces at lists.rawmode.org] On Behalf Of Daniel
Westermann-Clark
Sent: Thursday, December 15, 2005 5:33 PM
To: dbix-class at lists.rawmode.org
Subject: [Dbix-class] [Patch] PK::Auto documentation

Since the question seems to come up pretty often, here's a patch
against trunk describing basic usage of the PK::Auto classes.

Each PK::Auto::$database class has a synopsis, as does PK::Auto.  The
patch also explicitly notes that the PK::Auto::$database class should
be loaded before Core.

-- 
Daniel Westermann-Clark

-- 
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.14.1/204 - Release Date: 12/15/2005
 
    

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.14.1/204 - Release Date: 12/15/2005
 



-- 
----------------------------------------------------------------------------
This electronic message contains information from Primus Telecommunications
Canada Inc. ("PRIMUS") , which may be legally privileged and confidential.
The information is intended to be for the use of the individual(s) or entity
named above. If you are not the intended recipient, be aware that any
disclosure, copying, distribution or use of the contents of this information
is prohibited. If you have received this electronic message in error, please
notify us by telephone or e-mail (to the number or address above)
immediately. Any views, opinions or advice expressed in this electronic
message are not necessarily the views, opinions or advice of PRIMUS.
It is the responsibility of the recipient to ensure that
any attachments are virus free and PRIMUS bears no responsibility
for any loss or damage arising in any way from the use
thereof.The term "PRIMUS" includes its affiliates.
----------------------------------------------------------------------------
Pour la version en français de ce message, veuillez voir
 http://www.primustel.ca/fr/legal/cs.htm
----------------------------------------------------------------------------




More information about the Dbix-class mailing list