#2536: Mutually referential many-to-one relationship AddManipulator fails.
-------------------------+--------------------------------------------------
Reporter: anonymous | Owner: adrian
Status: new | Component: Database wrapper
Version: | Resolution:
Keywords: | Stage: Unreviewed
Has_patch: 0 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 0
-------------------------+--------------------------------------------------
Comment (by Marek Kubica <[EMAIL PROTECTED]>):
ramiro and bmurdock are right - this is caused by some name-clash (but in
my tests with the shell `Child.AddManipulator()` crashes always, not just
in the admin). Taking the first two models or ramiro's `models.py` that
gives us two models. To check it, I added two print statements to
source:django/trunk/django/db/models/manipulators.py#4458 between line 72
and 73:
{{{
print f.name
print self.follow
}}}
Now, trying to add a `Child` object with the admin shows (on stdout):
{{{
parent
{'id': True, 'parent': True, 'name': True}
}}}
As `self.follow.get(f.name, False)` yields `True`, the code inside the
`if` statement is executed, causing a crash. Trying to add a `Parent`
objects gives different results:
{{{
child
{'bestchild': True, 'id': True, 'name': True}
}}}
Now `self.follow.get(f.name, False)` really is `False`, so the code is not
executed. This seems to me to be some kind of misbehaviour, because it
looks up for the wrong attribute - if it looked up correctly, this would
have to be `True` as well, I think.
I suspect that this works only because it is looking up incorrectly (name-
clashes or whatever) - if it would look up correctly both
`Child.AddManipulator()` and `Parent.AddManipulator()` would crash. Sounds
paradoxical, indeed. Finally, it does not solve the whole problem, but the
wrong lookup causes some `AddManipulator` to fail and others not to fail.
To solve this problem the lookup mechanics need to be fixed first.
Unfortunately, I've got no idea whether `f.name` is wrong or the key in
`self.follow` is incorrect. Hopefully someone who knows more about the
internals of Django can tell me which one is to fix (or explain to me that
the lookup is correct).
--
Ticket URL: <http://code.djangoproject.com/ticket/2536#comment:11>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---