<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">You&#39;ll need to override ``__new__``. That&#39;s your hook. It&#39;s called<br>
when the database instantiates the object. Note that this is always<br>
true for Python. The ``__new__`` method is always called before an<br>
object is instantiated.<br></blockquote><div><br></div><div>Actually, this doesn&#39;t seem to be what I want. ``__new__`` is called</div><div>*before* any attributes are set on the instance... so it&#39;s too early</div>
<div>to tell whether the instance is missing the attribute, as it certainly</div><div>will (since it&#39;s missing any attributes).</div><div><br></div><div>Is there any hook to call *after* the instance attributes get set/loaded</div>
<div>from the database? </div><div><br></div><div>Here is my code that didn&#39;t work, in case I&#39;m just doing something silly:</div><div><br></div><div><div>class Line(Persistent):</div><div>    def __new__(cls, *args, **kwargs):</div>
<div>        inst = super(Line, cls).__new__(cls, *args, **kwargs)</div><div>        </div><div>        try:</div><div>            <a href="http://inst.id">inst.id</a>     #every instance in the DB already has an &#39;id&#39;</div>
<div>        except AttributeError:</div><div>            return inst</div><div>        print &#39;we are here...&#39; #this is never printed</div><div><br></div><div>        try:</div><div>            inst.expired  #the thing i actually want to guarantee</div>
<div>        except AttributeError:</div><div>            inst.expired = False</div><div>        </div><div>        return inst</div></div><div><br></div><div>Thanks,</div><div>- Claudiu</div></div>