<div class="gmail_quote">On Tue, Jun 19, 2012 at 2:29 PM, Malthe Borch <span dir="ltr"><<a href="mailto:mborch@gmail.com" target="_blank">mborch@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On 19 June 2012 19:54, Claudiu Saftoiu <<a href="mailto:csaftoiu@gmail.com">csaftoiu@gmail.com</a>> wrote:<br>
> That is, a function called whenever the object is loaded, that does all the<br>
> necessary backwards-compatibility<br>
> work right there. It separates the backwards-compat code cleanly, and also<br>
> only updates the objects<br>
> as-needed... though still a minor performance hit as it does the check each<br>
> time the object is loaded.<br>
><br>
> Is there a way to do that last option? What's the best practice for this<br>
> sort of thing, in general?<br>
<br>
</div>You'll need to override ``__new__``. That's your hook. It'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>Thanks, I wasn't aware. Seems to work - much appreciated!</div><div><br></div><div>- Claudiu</div></div>