Re: Multi Database use with statement

2008-12-30 Thread wei guangjing
#x27;db2') Wei guangjing - Original Message - From: "wei guangjing" To: Sent: Sunday, December 28, 2008 12:00 PM Subject: Re: Multi Database use with statement > Please see the attached patch for using in models's Meta option, I also like > this option. > &

Re: Multi Database use with statement

2008-12-28 Thread Ludvig Ericson
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() #

Re: Multi Database use with statement

2008-12-27 Thread wei guangjing
e use special db connection: enter_connection_management(connection) leave_connection_management() Wei guangjing - Original Message - From: "mtrier" To: "Django developers" Sent: Sunday, December 28, 2008 10:37 AM Subject: Re: Multi Database use with statement Hi

Re: Multi Database use with statement

2008-12-27 Thread alex.gay...@gmail.com
Personally I think I like Michael's suggestion of a using method on a queryset, and a default in Meta(pretty much the way ordering works). To his question of reusable applications I think the solution to that is actually something outside the scope of Django itself, a reusable's apps views should

Re: Multi Database use with statement

2008-12-27 Thread mtrier
Hi Wei, On Dec 27, 6:23 am, "wei guangjing" wrote: > Hi, > > I write a patch for using with statement in python 2.5 and up for multi > database access, example code like this: > > # test.py > from __future__ import with_statement > from django.contrib.auth.models import User > from django.db im

Multi Database use with statement

2008-12-27 Thread wei guangjing
Hi, I write a patch for using with statement in python 2.5 and up for multi database access, example code like this: # test.py 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 us