David De La Harpe Golden wrote: > Here's something further pared down I'm currently testing with django > 1.1.1 to tide us over until true multi-db for our own simple > multi-postgresql-database case. It "seems to work", though doesn't > address a bunch of stuff true multi-db would cover
> class ExtDBManager(models.Manager): ... Hmph. In case some poor soul stumbles on this thread in the archives- Turns out that didn't quite work as it was for many to many fields, as they try to construct a further subclass of the manager. So, a factory function that churns out instances of subclasses with the extra connection as a class field so that the further subclassing inherits the connection - i.e. def make_extdbmanager(conn, *args, **kwargs): if isinstance(conn, basestring): c = get_connection(conn) # just a convenience function else: c = conn class _ExtDBManager(models.Manager): connection = c def get_query_set(self): qs = super(_ExtDBManager, self).get_query_set() qs.query.connection = self.connection return qs return _ExtDBManager(*args, **kwargs) Yeah, this is probably all not the best idea ever, but all just to tide us over. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---