On 6/8/07, <b class="gmail_sendername">Guy Debord</b> &lt;<a href="mailto:situationist@gmail.com">situationist@gmail.com</a>&gt; wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
So is this not a good option if I want specific logic in Model::Foo but not Model::Bar ( I can&#39;t even create these without breaking )&nbsp;<div><br></div><div>This seems to run contrary to my reading of the documentation and tutorials, etc.
</div><div><br></div></blockquote></div><br><br clear="all">Hi Guy,<br>
<br>
I think that a diagram of how things are encapsulated would probably be of assistance.&nbsp; Sorry if I&#39;m covering stuff you already know, just want to make sure everything is thoroughly laid out.<br><br>First, it&#39;s important to know how things work outside of Catalyst.&nbsp; The DBIC classes you have can be used just like $schema-&gt;resultset(&#39;TableName&#39;), where $schema is (as I can see) a &quot;TMP::Schema&quot; object.
<br><br>The DBIC::Schema helpers basically create a short-hand for you to access &quot;TableName&quot;, but they make you use some prefix.&nbsp; This is really useful if you have a model in your app called &quot;User&quot; but you also have a schema class (a database table) named &quot;User&quot;
<br><br>As an example, something like this:<br>&nbsp;&nbsp; $c-&gt;model(&quot;User&quot;);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Just some other model class<br>&nbsp;&nbsp; $c-&gt;model(&quot;DB::User&quot;);&nbsp; # A DBIC class resultset, equivalent to doing $schema-&gt;resultset(&#39;User&#39;)
<br><br>So, just think that when you are doing &quot;$c-&gt;model(&quot;DB::SomeTable&quot;)&quot; you&#39;re doing the equivalent of $schema-&gt;resultset(&quot;SomeTable&quot;);&nbsp; And, as such, $c-&gt;model(&quot;DB&quot;) would be somewhat analogous to returning the $schema object -- except it doesn&#39;t, because that gets shoved off behind the scenes, and Model::DBIC::Schema&nbsp; creates a map between the -&gt;resultset(&quot;TableName&quot;) and model(&quot;DB::TableName&quot;) automatically, so you shouldn&#39;t need the $schema object to get at the result sets.
<br><br>The prefix there (&quot;DB::&quot;) is configurable via the helper scripts, but is very important (both for the reason I listed above w/ having other model classes) and the way that Catalyst::Model::DBIC imports your schema classes into your Catalyst application.
<br><br>The syntax that Matt posted:<br>script/tmp_create.pl model DB DBIC::Schema TMP::Schema<br><br>Breaks down like this:<br>You&#39;re creating (tmp_create.pl) a model, with a prefix of &quot;DB&quot; that inherits from &quot;DBIC::Schema&quot; and will use Helper::DBIC::Schema to generate the code.
<br><br>The arguments beyond there (&quot;TMP::Schema&quot;) are instructive to Helper::DBIC::Schema to know what to map against.<br><br>Helper::DBIC::Schema then creates a map of the prefix (&quot;DB&quot;) to &quot;TMP::Schema&quot;.
<br><br>You&#39;re on the right track though, and what you said in the original post about it getting &quot;ugly&quot; as the app grows I suppose is just a matter of perspective.&nbsp; You can always run without debugging enabled so you don&#39;t see how things get dumped out.&nbsp; But, it&#39;s all just information for you to look at. Even without the (&quot;DB::&quot;) prefix (or &quot;Foo::&quot; as you have in your example) you&#39;d still have to load each and every schema class into Catalyst so that -&gt;model(...) knows what to work with.
<br><br>Hope this helps clear things up,<br>-Jay<br><br>-- <br>J. Shirley :: <a href="mailto:jshirley@gmail.com">jshirley@gmail.com</a> :: Killing two stones with one bird...<br><a href="http://www.toeat.com">http://www.toeat.com
</a>