Re: QuerySetManager breakage with r14389

2011-01-12 Thread Ian Clelland
On Wed, Jan 12, 2011 at 6:23 AM, Russell Keith-Magee
 wrote:
> On Thu, Jan 6, 2011 at 5:29 AM, Ian Clelland  wrote:
>> Hi,
>>
>> I've been using Simon Willison's QuerySetManager[1] pattern for a
>> while now, and since upgrading to Django 1.2.4, it has been breaking
>> when I try to call a method on a RelatedManager constructed from it.
>>
>> There was a change in r14389 (14390 in the 1.2.X branch) which causes
>> this code to break -- where there was a simple delegation before from
>> the RelatedManager to the QuerySetManager to the model, there now
>> appears to be an infinite recursion, with the RelatedManager and
>> QuerySetManager trying to call each other's get_query_set methods.
>>
>> Has anybody seen this before? I am presuming that the change to
>> Django's related.py is correct, and that the QuerySetManager code just
>> needs to be updated to properly support Multi-db, but I don't know
>> where to start fixing it.
>
> Hi Ian,
>
> Sorry for taking so long to get back to you.
>
> No - I haven't seen this before; and I can't see an obvious reason
> that the snippet should have stopped working.
>
> If you want to make sure this is addressed, you should open a ticket
> in Trac. What you are report is an apparent regression in a recent
> changeset, so it would constitute a release-blocking bug for 1.3.

Thanks, Russ --

Looking at the QuerySetManager code, I couldn't tell if it was even
doing the right thing by unconditionally overriding __getattr__, or if
that was an incorrect solution that just happened to work until
related.py was fixed.

I've posted it on Trac, as ticket #15062.

(Glad to know it wasn't just lost in the noise :) )

Regards,
Ian Clelland


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: QuerySetManager breakage with r14389

2011-01-12 Thread Russell Keith-Magee
On Thu, Jan 6, 2011 at 5:29 AM, Ian Clelland  wrote:
> Hi,
>
> I've been using Simon Willison's QuerySetManager[1] pattern for a
> while now, and since upgrading to Django 1.2.4, it has been breaking
> when I try to call a method on a RelatedManager constructed from it.
>
> There was a change in r14389 (14390 in the 1.2.X branch) which causes
> this code to break -- where there was a simple delegation before from
> the RelatedManager to the QuerySetManager to the model, there now
> appears to be an infinite recursion, with the RelatedManager and
> QuerySetManager trying to call each other's get_query_set methods.
>
> Has anybody seen this before? I am presuming that the change to
> Django's related.py is correct, and that the QuerySetManager code just
> needs to be updated to properly support Multi-db, but I don't know
> where to start fixing it.

Hi Ian,

Sorry for taking so long to get back to you.

No - I haven't seen this before; and I can't see an obvious reason
that the snippet should have stopped working.

If you want to make sure this is addressed, you should open a ticket
in Trac. What you are report is an apparent regression in a recent
changeset, so it would constitute a release-blocking bug for 1.3.

Yours,
Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



QuerySetManager breakage with r14389

2011-01-05 Thread Ian Clelland
Hi,

I've been using Simon Willison's QuerySetManager[1] pattern for a
while now, and since upgrading to Django 1.2.4, it has been breaking
when I try to call a method on a RelatedManager constructed from it.

There was a change in r14389 (14390 in the 1.2.X branch) which causes
this code to break -- where there was a simple delegation before from
the RelatedManager to the QuerySetManager to the model, there now
appears to be an infinite recursion, with the RelatedManager and
QuerySetManager trying to call each other's get_query_set methods.

Has anybody seen this before? I am presuming that the change to
Django's related.py is correct, and that the QuerySetManager code just
needs to be updated to properly support Multi-db, but I don't know
where to start fixing it.

Thanks,
Ian


The simplest test case I can get to reproduce this problem looks like
this:

from django.db import models
from django.contrib.auth.models import User
from helpers import QuerySetManager

class TestModel(models.Model):
user = models.ForeignKey(User)
string = models.CharField(max_length=64, null=True, blank=True)
objects = QuerySetManager()
class QuerySet(models.query.QuerySet):
pass

>>> user = User.objects.get(username='testuser')
>>> user.testmodel_set.create(string="test")
Traceback (most recent call last):
  File "", line 1, in 
user.testmodel_set.create(string="test")
  File "/Users/ian/.virtualenvs/testcode/lib/python2.6/site-packages/
django/db/models/fields/related.py", line 423, in create
return super(RelatedManager, self.db_manager(db)).create(**kwargs)
  File "/Users/ian/.virtualenvs/egather/lib/python2.6/site-packages/
django/db/models/manager.py", line 138, in create
return self.get_query_set().create(**kwargs)
  File "/Users/ian/.virtualenvs/testcode/lib/python2.6/site-packages/
django/db/models/fields/related.py", line 410, in get_query_set
return
superclass.get_query_set(self).using(db).filter(**(self.core_filters))
  File "/Users/ian/Code/Tests/related_test/test_app/models.py", line
17, in __getattr__
return getattr(self.get_query_set(), attr, *args)
  File "/Users/ian/.virtualenvs/testcode/lib/python2.6/site-packages/
django/db/models/fields/related.py", line 410, in get_query_set
return
superclass.get_query_set(self).using(db).filter(**(self.core_filters))
  File "/Users/ian/Code/Tests/related_test/test_app/models.py", line
17, in __getattr__
return getattr(self.get_query_set(), attr, *args)
  File "/Users/ian/.virtualenvs/testcode/lib/python2.6/site-packages/
django/db/models/fields/related.py", line 410, in get_query_set
return
superclass.get_query_set(self).using(db).filter(**(self.core_filters))
  File "/Users/ian/Code/Tests/related_test/test_app/models.py", line
17, in __getattr__
return getattr(self.get_query_set(), attr, *args)
  File "/Users/ian/.virtualenvs/testcode/lib/python2.6/site-packages/
django/db/models/fields/related.py", line 410, in get_query_set
return
superclass.get_query_set(self).using(db).filter(**(self.core_filters))
  File "/Users/ian/Code/Tests/related_test/test_app/models.py", line
17, in __getattr__
return getattr(self.get_query_set(), attr, *args)
...
Lots snipped
...
  File "/Users/ian/.virtualenvs/egather/lib/python2.6/site-packages/
django/db/models/fields/related.py", line 410, in get_query_set
return
superclass.get_query_set(self).using(db).filter(**(self.core_filters))
  File "/Users/ian/Code/Tests/related_test/test_app/models.py", line
14, in get_query_set
return self.model.QuerySet(self.model)
  File "/Users/ian/.virtualenvs/testcode/lib/python2.6/site-packages/
django/db/models/query.py", line 33, in __init__
self.query = query or sql.Query(self.model)
  File "/Users/ian/.virtualenvs/testcode/lib/python2.6/site-packages/
django/db/models/sql/query.py", line 138, in __init__
self.aggregates = SortedDict() # Maps alias -> SQL aggregate
function
  File "/Users/ian/.virtualenvs/testcode/lib/python2.6/site-packages/
django/utils/datastructures.py", line 97, in __init__
super(SortedDict, self).__init__(data)
RuntimeError: maximum recursion depth exceeded while calling a Python
object

[1] http://djangosnippets.org/snippets/734/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.