On 12 mai 2013, at 03:36, Anssi Kääriäinen <[email protected]> wrote:

> Concrete API proposal: Model.refresh() reloads all non-deferred local
> field values (that is, all fields in the current model which have a
> database column). In addition refresh() will make sure that cached
> values dependent of the reloaded values will be cleared. That is, if
> you do foo.refresh(), then when foo.user_id is reloaded foo.user will
> be cleared (assuming the reloaded user_id is different from the
> original value). This is to ensure that next access to foo.user will
> reload the related object, too.
> 
> The refresh() method makes sure descriptors are honored, for example
> custom field's to_python() method will be called for refreshed values.

That sounds good to me.

> The refresh() method accepts *args, so that one can specify which
> fields to reload. This is useful so that deferred attribute loading
> can use refresh(), and by overriding refresh() it will be possible to
> customize how deferred loading happens.
> 
> Deferred field loading is altered to use .refresh().

I'm not totally following you here. I suppose it would make sense if I were
more familiar with the implementation.

> It might be useful to add model.deferred_fields property. The property
> returns a set of currently deferred fields in the instance. If this
> was available it would be easy to force reload of all currently
> deferred fields, but no reload of other fields. This would also be
> useful for loading all deferred fields when any deferred field is
> accessed. But this can wait for later…

Yes, that would be an internal API anyway.

> Does the proposal look acceptable?

Yes.

My only objection to this ticket was the lack of a concrete proposal!

-- 
Aymeric.

-- 
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