On Jan 10, 12:19 pm, Zachary Voase <[email protected]> wrote:
> It should be relatively simple to allow QuerySets to know which
> manager they came from, and then override __getattr__ to use the
> declared @querymethod from that manager (instead of the other way
> around). This avoids the unpickleable QuerySet subclass problem.
Passing knowledge of which manager the method came from is trivial.
Just set qs.manager = self.__class__ in manager.get_query_set() and
use qs.manager in __getattr__.
However, I would like it if you could mix methods from different
managers. Maybe add qs.set_manager(manager_name), and so you could do:
SomeModel.objects.order_by('id').some_manager_method().set_manager('other_manager').some_manager_method_in_other_manager().
set_manager would simply change the qs.manager. This way you could
change the manager which is looked for chainable methods, and all
chainable methods would be available from all managers.
I hoverer do like the idea that you have all the methods defined in
any manager directly available in the queryset, without the need to
use set_manager. This is easy to achieve.
Thoughts?
- Anssi
--
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?hl=en.