On Sat, May 11, 2013 at 7:55 PM, Russell Keith-Magee <
[email protected]> wrote:

> I'm sure I understand this argument. Python objects are passed around by
> reference, not by value, so if you've passed in a Django object deep into
> another library, that library will be pointing at the same instance. If the
> instance is changed, everywhere holding a handle to that reference will be
> updated.
>

Yes, but that is not what foo = MyObj.objects.get(id=foo.id) does. That
assigns a new reference to a new object to the name foo. Other references,
even references to the same instance as foo, are not refreshed. This is
precisely why a .reload() method is useful -- what is wanted is to mutate
the instance that is referred to, not to create a new reference and assign
it to the old name.

To that end - I want to make sure that we're clear about what we're talking
> about here.
>
> What is on the table is essentially adding a refresh() call on an object
> instance that is an API analog of ".get(id=self.id)" (although the
> implementation will need to do a bit more than that).
>

It's not really the same at all, .reload() or .refresh() would the existing
instance in place. It's more akin to foo.__dict__ = MyObj.objects.get(id=
foo.id).__dict__

Best,
Alex Ogier

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-developers?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to