<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
<br><div><div>On 29 May 2009, at 19:43, Jarom Smith wrote:</div><blockquote type="cite"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Pretend I'm a complete ignoramus... (that shouldn't be too hard, LOL) If I were to want to submit a "doc patch", how would I go about doing it and what exactly would I be submitting?</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br></div></blockquote><div><br></div><div>Right, so there are two things we want:</div><div><br></div><div>1) Documenting the answer to your question</div><div>2) Making that answer easy to find.</div><div><br></div><div>So lets go back in time a little:</div><div><br></div><div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On 27 May 2009, at 17:59, Jarom Smith wrote:</div><blockquote type="cite"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; ">In a Catalyst context, where do I put these kinds of "helper" DB methods and how do I access them? (both from within a Catalyst app, as well as from the command-line like in a Cron job or whatever...)  Some actual specific examples would be great.  I'm sure there is a way, and I'm guessing it involves the model somehow (possibly by creating a new model class?) but I haven't been able to figure it out yet.  I tried adding methods to the classes created by Catalyst/DBIC in the Schema/Result directory, but gradually it dawned on me that methods placed here are only dealing with a single entity of that type.  To go back to Java-speak, it seems like the stuff in Schema/Result are DTO methods; what I'm trying to figure out is how/where to put the DAO methods.</font></div></blockquote></div><br></div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">So I guess the most obvious place for this doc would be in Catalyst-Model-DBIC-Schema - or at least, the documentation there should point you in the right direction!</div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br></div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Are there any other significant places you looked for documentation where it should also be mentioned? (You know - you just searched!)</div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br></div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">And I guess that some of this is already documented in DBIx::Class::Schema::Loader.. So go read the documentation around there, and make a call about what should be added to the documentation there (if anything), what should be added in Catalyst::Model::DBIC::Schema, and any other places you think you should link it from..</div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br></div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Then check the relevant projects out of subversion:</div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br></div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><a href="http://dev.catalyst.perl.org/repos/Catalyst/trunk/Catalyst-Model-DBIC-Schema/">http://dev.catalyst.perl.org/repos/Catalyst/trunk/Catalyst-Model-DBIC-Schema/</a></div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><a href="http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class-Schema-Loader/">http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class-Schema-Loader/</a></div></div><div><a href="http://dev.catalyst.perl.org/repos/Catalyst/Catalyst-Manual/5.80/trunk/">http://dev.catalyst.perl.org/repos/Catalyst/Catalyst-Manual/5.80/trunk/</a></div><div><br></div><div>Are the things I guess you may want to be patching.</div><div><br></div><div>Add some POD as you think is relevant (and use pod2text and/or pod2html to check it looks ok), make sure the tests still pass (as they'll test the pod structure for you), then when you're happy, svn diff and attach the diff to an email..</div><div><br></div><div>Someone will then review and apply, or send you some comments back. If you do this more than a couple of times, someone will hand you a commit bit so you can just commit directly.</div><div><br></div><div>Note the patch to DBIx-Class-Schema-Loader (if you think one is appropriate) is best sent to the dbic list.</div><div><br></div><blockquote type="cite"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">One revelation I had recently which I don't think has been mentioned anywhere (at least not that I recall) is that when using DBIC and Catalyst, *everything* is treated as a scalar.<span class="Apple-converted-space">  </span>(is this a true statement?)<span class="Apple-converted-space">  </span>So in other words,</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">my $people = $c->model('AddressDB::People')</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">instead of</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">my @people = <span class="Apple-style-span" style="-webkit-text-stroke-width: -1; ">$c->model('AddressDB::People')</span></div></blockquote><div><br></div>Erm, I think you're a bit confused.</div><div><br></div><div>When you ask for: my $people = $c->model('AddressDB::People'), then you get an instance of a ResultSet (i.e. a blessed scalar). This doesn't hit the DB with a query.</div><div><br></div><div>To give you a list back, there have to be things in the list - ergo you need to go to the db.</div><div><br></div><div>my @people = $c->model('AddressDB::People')->all will do this for you, but beware, this will suck your entire table into RAM...</div><div><br></div><div><blockquote type="cite"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">This hit me while reading p. 41 of the book.<span class="Apple-converted-space">  </span>I'm not even totally sure it's correct but things seem to work better when I adopt this view-point, so it probably is correct.<span class="Apple-converted-space">  </span>It kind of makes sense, because the Catalyst stash stores things using scalars (strings) as keys, so if you just think of everything as a scalar (which could be a ref to an array or hash) then things become slightly less confusing.<span class="Apple-converted-space">  </span>At least, that's my current understanding.<span class="Apple-converted-space">  </span>I am still very much muddling my way through all this stuff.</div></blockquote><div><br></div>Erm, it's up to the specific method invoked what it wants to return.</div><div><br></div><div>Some methods implicitly behave differently when called in list or scalar context, some don't.</div><div><br></div><div>That's just perl.<br></div><br><div>Cheers</div><div>t0m</div><div><br></div></body></html>