<br><br><div><span class="gmail_quote">On 9/28/06, <b class="gmail_sendername"><a href="mailto:leonard.a.jaffe@jpmchase.com">leonard.a.jaffe@jpmchase.com</a></b> &lt;<a href="mailto:leonard.a.jaffe@jpmchase.com">leonard.a.jaffe@jpmchase.com
</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br><font face="sans-serif" size="2">Brian Cassidy wrote:</font>
<br><font face="sans-serif" size="2">&nbsp; &nbsp; &nbsp; &nbsp; </font>
<br><font face="sans-serif" size="2">&gt; Jon Warbrick wrote:</font>
<br><font face="sans-serif" size="2">&gt; &gt; Can a Catalyst::Model::DBIC::Schema
model be configured from a YAML </font>
<br><font face="sans-serif" size="2">&gt; &gt; file via Catalyst::Plugin::Config::YAML?
If so, how? Apologies if it's in </font>
<br><font face="sans-serif" size="2">&gt; &gt; the documentation somewhere,
but if so I've yet to find it...</font>
<br><font face="sans-serif" size="2">&gt; &gt; &nbsp; </font>
<br><font face="sans-serif" size="2">&gt; in myapp.yml</font>
<br><font face="sans-serif" size="2">&gt; </font>
<br><font face="sans-serif" size="2">&gt; Model::MyModel:</font>
<br><font face="sans-serif" size="2">&gt; &nbsp; schema_class: MySchema</font>
<br><font face="sans-serif" size="2">&gt; &nbsp; connect_info:</font>
<br><font face="sans-serif" size="2">&gt; &nbsp; &nbsp; - dbi:blahblah</font>
<br><font face="sans-serif" size="2">&gt; &nbsp; &nbsp; - username</font>
<br><font face="sans-serif" size="2">&gt; &nbsp; &nbsp; - password</font>
<br>
<br><font face="sans-serif" size="2">While we're on the subject, lets assume
that MySchema is 'myapp::SchemaLoader::foo.</font>
<br>
<br><font face="sans-serif" size="2">How do I make sure that my SchemaLoader
can see the config when it tries to execute</font>
<br><font face="sans-serif" size="2">__PACKAGE__-&gt;connection?</font>
<br>
<br><font face="sans-serif" size="2">It isn't seeing the Model::MyModel connect_info,
admonishing me for failing to provide </font>
<br><font face="sans-serif" size="2">connection info.</font></blockquote><div><br><br>As with all things Perl, TIMTOWTDI.&nbsp; While you *can* specify the connection in the Schema, its generally not a great idea.<br><br>Best practice would be that myapp::SchemaLoader::foo should just contain the &quot;loader_options&quot; method, and really nothing else (no connect/connection call).&nbsp; Then when the Model makes the connection using your connect_info configuration, that's when the actual dynamic loading will happen.
<br><br>Even better practice would be to use the helper in create=static mode instead of create=dynamic, so that you're not re-scanning the table definitions at every server start.&nbsp; If you insist on maintaining your database the old-fashioned way (or have no control over it), you can regenerate via create=static each time there's a change in the DDL, and diff versus the previous version to see the changes, etc.
<br><br>The next step beyond that is to start maintaining your database tables using the generated DBIC schema and the SQLT/-&gt;deploy support.&nbsp; Then you won't need Loader at all.<br><br>Another good practice is to move the Schema definitions outside of the myapp:: Catalyst-app namespace, so that you can deploy the Schema independantly for other tools that might need access to your database.
<br></div><br>[maybe I should make a best practices section in the Schema::Loader pod?]<br><br>-- Brandon<br><br></div>