<div class="gmail_quote">Thanks James,<div><br></div><div>I&#39;m surprised there isn&#39;t a trick - perhaps something that can be added in the class definition - where I can force the object to load with the reference, for situations where I&#39;ll be loading large numbers of rows, all of which will require access to the related table. I&#39;d seen the option to load multiple objects in the tutorial, but it&#39;s a bit messy compared to simply accessing the Reference of an object.</div>

<div><br></div><div>It seems to be a pretty typical feature in other ORMs (mainly php) that I have used.</div><div><br></div><div>I will continue to investigate.</div><div><br></div><div>Cheers,</div><div>Pete<br><br><div class="gmail_quote">

2009/9/18 James Henstridge <span dir="ltr">&lt;<a href="mailto:james@jamesh.id.au" target="_blank">james@jamesh.id.au</a>&gt;</span><div><div></div><div class="h5"><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div><div></div><div>On Wed, Sep 16, 2009 at 9:00 PM, peter websdell<br>
&lt;<a href="mailto:flyingdeckchair@googlemail.com" target="_blank">flyingdeckchair@googlemail.com</a>&gt; wrote:<br>
&gt; Hello all,<br>
&gt; I&#39;m new to Storm and this list.<br>
&gt; I have assumed so far that storm uses lazy-loading to get attributes from<br>
&gt; relations. Is it possible to specify auto loading of related tables? If so,<br>
&gt; can it be done on-the-fly, rather then in the class definition?<br>
<br>
</div></div>When you access a &quot;Reference&quot; attribute on an object, Storm will<br>
perform a store.get() call to retrieve the related object.  If the<br>
object has already been loaded, then it will be returned directly.  If<br>
it hasn&#39;t, this will result in a query.<br>
<br>
If you want to retrieve pairs of objects in a single query, you can do<br>
that with store.find().  Something like this:<br>
<br>
class A(object):<br>
    __storm_table__ = &quot;a&quot;<br>
    id = Int(primary=True)<br>
<br>
class B(object):<br>
    __storm_table__ = &quot;b&quot;<br>
    id = Int(primary=True)<br>
    a_id = Int()<br>
    a = Reference(a_id, A.id)<br>
<br>
result = store.find((B, A), B.a_id == A.id)<br>
for (b, a) in result:<br>
    # The following won&#39;t issue a query, because &quot;a&quot; was loaded at the<br>
same time as &quot;b&quot;.<br>
    assert b.a == a<br>
<br>
Hope this helps,<br>
<font color="#888888"><br>
James.<br>
</font></blockquote></div></div></div><br></div>
</div><br>