Was there a suggestion on how to deal with multiple databases with the
same tables? I have an admin database that has content-related tables
that periodically get "published" to the live database. I was
wondering if anyone had a suggestion about how to re-use an SQLObject
class definitions with multiple _connection objects.
--T
On Wednesday, August 27, 2003, at 01:43 PM, Tracy S. Ruggles wrote:
> Is there a better way to handle multiple connections of a single table
> than this:
>
>> class mytable(SQLObject):
>> _connection = localConnection
>> name = StrCol(length=255)
>> data = StrCol()
>>
>> localdata = mytable.select()
>> # change connection
>> mytable._connection = remoteConnection
>> remotedata = mytable.select()
>> # change it back...
>> mytable._connection = localConnection
>
> The object returned by the two different connections are actually
> different objects and update properly through the right database
> connection, but any related objects returned through a RelatedJoin are
> the same, using the current connection. Is there a better way to do
> this?
>
> I thought I might be able to do this:
>
>> class mytableRemote(mytable):
>> _connection = remoteConnection
>
> ...but it doesn't seem to work. Or, I thought I could just sub-class
> SQLObject...
>
>> class mySQLObject(SQLObject):
>> _connection = localConnection
>> def connectRemotely(self):
>> self.__class__._connection = remoteConnection
>> def connectLocally(self):
>> self.__class__._connection = localConnection
>
> I know that I can duplicate my table definition modules and just give
> each one a different connection object, but I want to be able to
> re-use the class definitions...
>
> Thanks,
> Tracy
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> sqlobject-discuss mailing list
> sql...@li...
> https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
>
|