On Sun, 2006-06-25 at 22:39 +0800, Russell Keith-Magee wrote: > On 6/25/06, Ivan Sagalaev <[EMAIL PROTECTED]> wrote: > > > > I'd like to draw some attention to ticket > > http://code.djangoproject.com/ticket/2232 (mainly russelm's attention as > > it appeared after his checkin 3195). > > Paying attention now :-) > > > Basically ManyToMany relations don't work when you try to get related > > queryset from a model where ManyToManyField is defined. Or is it just me? > > For me, all the regression tests passed at time of checkin. Following > the rest of the messages on this thread, it looks like the problems is > with model importing. 2 quick observations which might help find the > problem: > > 1) r3195 did make some changes to the model importing process, so this > might have changed the conditions under when any previous __import__ > related bug revealed itself > > 2) I have seen the behaviour from r1796 before - for me, the problem > ultimately turned out to be caused by a PYTHONPATH that included the > application directory (so "from myapp.models import Foo" and "from > myproject.myapp.models import Foo" were both legal). At the time, I > chalked it up to the pythonpath, and moved on (sorry - can't give any > more specific details as to SVN revision, exact code structure, etc). > > I don't know if this helps anyone - however, I thought it might yield > a reliably broken test case.
I've just checked in r3202 which I believe fixes the root cause of #1796 in a reasonably correct way. I think it also fixes #2232 for the same reason. It all seems to come down to the import paths being used as dictionary keys and models being registered twice. See the change for the way I am working around this. Russ: can you see if I've overlooked any problem there, please. It took a little while to track everything down and my brain may have gotten twisted in the process. Also, I left it alone for now and I realise you were just cutting-and-pasting, but __import__ takes dictionaries as the second and third arguments (globals() and locals(), basically, although the third arg is essentially ignored); why are we passing in strings??? I can no longer cause #1796 or anything like it to fail -- and I had a couple of failing examples there. I believe relative imports (appname.models, etc) might now work reliably too (experiments suggest they do), which means you no longer are reliant on your project name and can create portable apps. Feedback welcome/appreciated. I may have screwed up in some subtle way. Regards, Malcolm --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" 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-developers -~----------~----~----~----~------~----~------~--~---
