[Dbix-class] Schema::Loader and has_many

Vsevolod (Simon) Ilyushchenko simonf at cshl.edu
Thu Mar 23 00:10:49 CET 2006


Brandon,

So I got the relationships to work, but now I'm trying to turn on 
session support via Catalyst::Plugin::Session::Store::DBIC, and it's 
seems incompatible with the Loader. The test script t/05dbic-schema.t 
seems to be using schemas, but not the loader, and I can't reconcile the 
two.

Here's the furthest I've gotten -  Catalyst::Model::DBIC::Schema->new 
should create the method ACCEPT_CONTEXT in the model class, which 
enables Session::Store::DBIC to work properly. This method is created on 
line 188.

For the script t/05dbic-schema.t, the value of $class is 
'TestApp::Model::DBICSchema', and the value of $moniker is 'Session', so 
the method is created in TestApp::Model::DBICSchema::Sesion. (The 
TestApp code is in the t/lib subdirectory of 
Catalyst::Plugin::Session::Store::DBIC).

In my app at this point, $class is 'CSHL::Cat::Proto::M::Session', and 
$moniker iterates over all my model class names, including 'Session', so 
the ACCEPT_CONTEXT is uselessly created in 
'CSHL::Cat::Proto::M::Session::Session' etc.

The difference between the applications is that I have the recommended 
setup of App::Schema.pm, App::Schema::Session.pm and App::M::Session.pm 
(which is ISA Catalyst::Model::DBIC::Schema, as recommended). While 
TestApp::Model::DBIC::Session is ISA TestApp::Model::DBIC, plus they 
have TestApp::Model::DBICSchema, which is ISA 
Catalyst::Model::DBIC::Schema.

I'm not sure how to tie these approaches together.

Thanks,
Simon

Brandon Black wrote on 03/22/2006 11:58 AM:
> On 3/22/06, Vsevolod (Simon) Ilyushchenko <simonf at cshl.edu> wrote:
> 
>>Thanks! It works now. So what is the purpose of even having the M tree?
>>Just deceiving Catalyst into thinking that there is a model after all?
>>
> 
> 
> Catalyst::Model::DBIC::Schema is just a way to make a convenient
> Catalyst model that references an external Schema class.  There really
> is a model, not just a deception, and it is a little bit different
> than what you would get if you simply created your Schema under the
> "M" or  "Model" directory.  For instance, it provides resultset
> shortcuts as $c->model('MySchema::SomeTable').
> 
> Another way to think of it is that Catalyst::Model::DBIC::Schema is a
> DBIx::Class::Schema<->Catalyst::Model adaptor of sorts.


-- 

Simon (Vsevolod ILyushchenko)   simonf at cshl.edu
				http://www.simonf.com

"Think like a man of action, act like a man of thought."

		         Henri Bergson



More information about the Dbix-class mailing list