--
Best regards, Yuri V. Baburov, ICQ# 99934676, Skype: yuri.baburov,
MSN: bu...@live.com
FWIW, I like the idea. The more "hooks" added into the framework is a
good thing. I also like how your test implementation does not disrupt
current structure that is already in place.
Michael Trier
blog.michaeltrier.com
Indeed. If two applications each rely on different QuerySet classes,
something more fine-grained than a global setting will be needed for
them to peaceably coexist; I'd much prefer some standardized way of
extending the functionality, something we already have to an extent
via the ability to override get_query_set() in a custom manager.
--
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."
Agreed. In fact, this exact suggestion was made during the recent
discussions about adding aggregates. I'd much rather see per-manager
customization of Query Sets, rather than a global setting.
Yours,
Russ Magee %-)
I don't like this, since it's not actually usable (in the sense that it
doesn't add anything) in this form. Your earlier example had you
attaching a get_custom_manager() method to, e.g., the User model, but
there's no way to say what that method should return.
If you want to be able to specify a different default manager for some
particular use of an existing model, you're sort of after a third type
of model subclassing that I've thought about but haven't implemented:
subclassing an existing model and explicitly telling Django that this is
only Python-level (and not database-/ORM-level) inheritance. So all the
database interactions are part of the parent class(es) and the child
class simply adds extra functional pieces (such as a new default
manager). Nothing existing so far rules out adding this, so it's not
something that has to be resolved now, which is why I haven't wasted any
brain cells on it so far. This might be fairly easy to add once we work
out how to spell it, since it's only saying "create absolutely no fields
for this model, not even links back to the parent model and definitely
don't create a database table."
Then something that wanted to use a different manager (which is really
what you are meaning when you say "different queryset") with a model
would subclass it in this fashion and add their own manager to the
subclass. Existing code doesn't care about the new behaviour of your
custom manager and can safely rely on the existing behaviour it is used
to (which is a good thing: you don't sabotage existing code. Existing
code uses the original model class). Your new code can use the subclass
to be explicit that it wants the new queryset and that's fine, since
it's new code that you are writing to take advantage this, so it's
hardly a burden to have to write UserSubclass instead of User.
Malcolm
--
Atheism is a non-prophet organization.
http://www.pointy-stick.com/blog/
I've invested a few brain cells on this already, though not enough for
a complete solution. It'd be off-topic for this discussion, but
if/when you get around to it, feel free to hit me up if you're looking
for another opinion on how it could be done.
-Gul