On Dec 27, 2008, at 12:23, wei guangjing wrote:
> from __future__ import with_statement
> from django.contrib.auth.models import User
> from django.db import using
>
> with using('db1'):
>    print User.objects.count() # db1 user count
>    with using('db2'):
>        print User.objects.count() # db2 user count
> print User.objects.count() # default db user count

A few thoughts:
  - How will Django know which database is "chosen"? It would need  
some kind of thread-global storage to know. That's, IMO, not very nice.
  - Is "using" really such a great name? If I look at it, I don't  
really associate to databases or anything like it.
  - Isn't the QuerySet object responsible for knowing what to query?  
Like:
      db1_count = User.objects.at("db2").count()

As for reusability, it becomes sort of a tough situation for app  
developers if they're responsible entirely for defining which database  
takes care of what - if you'd use the QuerySet-centered way, you'd be  
able to pass that to generic views, for example.

These are just my thoughts, though.

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to