Re: [Django] #14484: database router ignored on Manager.get()

2010-12-04 Thread Django
#14484: database router ignored on Manager.get()
---+
  Reporter:  qMax | Owner:  nobody 
   
Status:  closed| Milestone: 
   
 Component:  Database layer (models, ORM)  |   Version:  1.2
   
Resolution:  worksforme|  Keywords:  
sprintdec2010, multiple databases, router, manager
 Stage:  Unreviewed| Has_patch:  0  
   
Needs_docs:  0 |   Needs_tests:  0  
   
Needs_better_patch:  0 |  
---+
Changes (by aweakley):

  * keywords:  multiple databases, router, manager => sprintdec2010,
   multiple databases, router, manager
  * status:  new => closed
  * resolution:  => worksforme

Comment:

 I can't repeat the behaviour described using a router as described above,
 and the following model code:

 models.py
 {{{
 class Category(models.Model):
 title = models.CharField(max_length=127)
 db_name = 'other'

 def __unicode__(self):
 return self.title
 }}}

 settings.py

 {{{
 DATABASE_ROUTERS = ['example.routers.DBRouter',]
 }}}

 session:
 {{{
 In [1]: from example.models import Category

 In [2]: Category.objects.get(id=1)

 Out[2]: 

 In [3]: Category.objects.all().get(id=1)

 Out[3]: 

 In [4]: Category.objects.all().db

 Out[4]: 'other'

 }}}

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

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



Re: [Django] #14484: database router ignored on Manager.get()

2010-10-18 Thread Django
#14484: database router ignored on Manager.get()
---+
  Reporter:  qMax | Owner:  nobody 

Status:  new   | Milestone: 

 Component:  Database layer (models, ORM)  |   Version:  1.2

Resolution:|  Keywords:  multiple 
databases, router, manager
 Stage:  Unreviewed| Has_patch:  0  

Needs_docs:  0 |   Needs_tests:  0  

Needs_better_patch:  0 |  
---+
Changes (by qMax ):

  * needs_better_patch:  => 0
  * needs_tests:  => 0
  * needs_docs:  => 0

Comment:

 not manager behaviour, but actually a queryset.
 calling objects.all() is not sufficient, of course.
 either len() or iterator should be called befor using .get()

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

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



[Django] #14484: database router ignored on Manager.get()

2010-10-18 Thread Django
#14484: database router ignored on Manager.get()
-+--
 Reporter:  qMax|   Owner:  nobody
   Status:  new  |   Milestone:
Component:  Database layer (models, ORM) | Version:  1.2   
 Keywords:  multiple databases, router, manager  |   Stage:  Unreviewed
Has_patch:  0|  
-+--
 {{{ModelInNondefaultDatabase.objects.get(key=val)}}}
 attempts to use default database, if called before
 {{{ModelInNondefaultDatabase.objects.all()}}}
 if .all is called first, .get uses proper database

 router is trivial:

 {{{
 class DBRouter(object):
   def get_db(self, model):
 return model.db_name

   def db_for_read(self, model, **hints):
 return model.db_name

   def db_for_write(self, model, **hints):
 return model.db_name

   def allow_relation(self, obj1, obj2, **hints):
 return False

   def allow_syncdb(self, db, model):
 return False
 }}}

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

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