Russell Keith-Magee wrote:

>1) What should be the behaviour of __set__ for descriptors where
> multiple values are allowed (ForeignKey, ManyToManyField)?

> Known Objections:
> Kieren Holland suggested that Article.reporter_set = [r1,r2] implies
> that reporter_set is an ordered collection, because of the use of a
> list in the assignment. Kieren believes that any automatic data
> conversion (in this case, list into set) is a bad idea, and
> potentially confusing. Therefore, __set__ should raise a TypeError if
> used on a many-object descriptor.

Thanks for the nice roundup.  Votes may be in but just to clarify: my
primary objection is that assignment is fundamentally a name-binding
operation in Python and in this case what is bound to the name is not
what is returned.  So I think a method would be more in keeping with
Python e.g.:

Article.reporter_set.create([r1,r2])

meaning that Jacob would have:

Artical.reporter_set.create(Reporter.objects.filter(...))

> 4) Reverse descriptors and save() have an interesting relationship. Given:

> a) make add()/remove()/clear()/__set__ implicit save points. This
> would have the added bonus of making ForeignKey add() etc mirror
> ManyToMany add() behaviour (since m2m table additions occur
> immediately, where ForeignKey add()'s are not applied until save() on
> the underlying objects)

Would there be a way to create non-persistent instances with relations?
I think it's important to keep this possibility open.  Several times
I've found it useful to use "throw-away" model instances for rendering
templates.

> b) make save() cascade into related objects - r1.save() cascades the
> a1.save() call because of the relation. However, a1.save() wouldn't
> have to cascade into r1.save()

This is the behaviour I would prefer but I am not sure about the
difficulties of implementation.

Cheers,
Kieran


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers
-~----------~----~----~----~------~----~------~--~---

Reply via email to