Ian Bicking wrote:
> nI added a new, somewhat experimental feature to SVN. You can now
> access attributes of dbconnection instances for each class, and you get
> a wrapper that acts like the class except the connection argument will
> be passed into class methods when necessary. It's a little hackish
> right now -- it looks for a "connection" argument name specifically --
> and I'm not sure about the performance. But I think it will be
> convenient and we can probably fix those problems.
> You use it like:
> conn = connectionFromURI('blah blah')
> class MyClass(SQLObject):
> inst = conn.MyClass(blah blah)
> for row in conn.MyClass.select(): ...
> And so on. Of course, you can do stuff like:
> self.MyClass = conn.MyClass
> And whatnot -- I think this will be useful in framework like systems
> that may configure connections or transactions internally. I suppose
> it's similar in function to sqlo's use of a property for _connection and
> per-thread connections; I can actually imagine adding that as a standard
> feature as well. Maybe that would make this technique redundant, but I
> think this way feels a little more transparent.
> This should work with transactions as well, but I haven't tested it, and
> it's a little tricky. Hmm... I should probably copy the transaction
> test and convert it to use this syntax and retest. But anyway...
> I'm interested in any feedback people have from using this.
Can this be used to connect same scheme to several databases?
con1 = ...
con2 = ...
for row1,row2 in zip(con1.MyClass.select(), con2.MyClass.select()):