On Tue, May 06, 2008 at 12:19:05PM -0700, [EMAIL PROTECTED] wrote:
> On Tue, May 06, 2008 at 10:53:29PM +0400, Oleg Broytmann wrote:
> > > Isn't a goal for ORMs to hide all this database connection stuff?
> > 2. There is no way for an ORM to guess where you do want to connect to.
>
> Yes but couldn't this be done in a config file rather than in Python code?
SQLObject is a library, not a framework that dictates the format and the
location of its config file(s).
> Unless I'm missing something,
> this is *already* done in TurboGears/SQLObject as the config
> file there defines a sqlobject.dburi variable!
Don't know anything about TurboGears. SQLObject is a separate project,
not a subproject of TG.
On Tue, May 06, 2008 at 11:53:31AM -0700, [EMAIL PROTECTED] wrote:
> In my TurboGears/SQLObject app, I manually commit changes to the database
> with a line like the following...
>
> MyObject._connection.commit()
Ah, that is what you meant by saying "explicit connection". I see now.
> It works but looks ugly since _connection is "private variable" that should
> not
> be accessed right?
Yes, to a degree. On the other hand, .commit() really belongs to the
connection. After a program has manipulated a hundred of SQLObjects it has
to fix the changes in the backend; .commit() doesn't belong to any
SQLObject in particular, it's a feature of the connection; if the
connection dies the backend automatically rollbacks changes.
I usually keep a reference to the connection, so I don't need to extract
it from SQLObjects:
connection = ...
class MyTable(SQLObject):
_connection = connection
new_row = MyTable(**values)
connection.commit()
What other API would you like to propose?
Oleg.
--
Oleg Broytmann http://phd.pp.ru/ [EMAIL PROTECTED]
Programmers don't die, they just GOSUB without RETURN.
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss