On May 21, 2:16 pm, "Jacob Kaplan-Moss" <[EMAIL PROTECTED]>
wrote:
> * There needs to be an official API to get a model (or perhaps a
> manager) which references a different "context" --
> ``Model.objects.db`` should be read-only. So you'd call some API
> method, and get back a sort of proxy object that uses the other
> connection. Here's a strawman API::
>
>     >>> from django import db
>     >>> from someapp.models import Article
>
>     >>> Article.objects.all()
>     [... all Articles from the default database ...]
>
>     >>> ArticlesOnOtherDatabase =
> db.get_model_for_other_connection(Article, "private")
>     >>> ArticlesOnOtherDatabase.objects.all()
>     [... all Articles from the database defined with the "private" key ...]
>

Has anybody considered declaring the connection when getting the
manager? Something like:
Artist.objects.all()
Widget.objects(db='a').all()
Obviously with the default database for the case when "db" isn't
passed. Also you could override the Manager to use a different
database by default (e.g. Widget.objects.all() might always use an
OTHER_DATABASE while all other models use the main db, if you create a
custom Manager for Widget)

This still leaves questions about how syncdb would be achieved, at
least. But if it could be done, the API seems simple to understand.

 -rob
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
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