Re: [SQLObject] Re: SQLObject / FireBird / WebWare
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Randall R. <ra...@ra...> - 2003-09-29 16:55:58
|
On Monday, September 29, 2003, at 09:46 AM, Ian Sparks wrote: > "Randall Randall" <ra...@ra...> wrote in message > news:B6C...@ra...... > I'm guessing that something like : > > #mypage.py: > from WebKit.Page import Page > import MySOClasses This is what I did, yes, though it was actually from SiteSQL import * since I have lots of SO objects in different files. > class mypage(Page): > ... > def writeContent... > test = MySoClasses.MyObject(1) > test.name = 'Fred' > > I'm assuming that if I have another servlet that has similar code that > the > two servlets share : > > 1. A database connection. > 2. The same SQLObject cache manager > > Overall my assumption is that in MySOClasses.py I define a database > connection and the SQLObject classes I want to use and then I'm free > to use > them in any servlet just by doing an "import MySOClasses" and that any > threading and cache management issues are handled for me? That's been my assumption, and so far has been working. :) If you expect to have issues with threading and flush caching, then you'd want to use transactions, but currently I just restart the appserver for major changes (it's not a financial site, just articles and such). I have a DBObject.py , which all my SQLObjects inherit from: ------------------------ from SQLObject import * conn = PostgresConnection("user=myuser dbname=mydb password=mypass") #trans = conn.transaction() class DBObject(SQLObject): '''Base SQLObject for building database objects''' #_cacheValues = False _connection = conn -------------------------- but which doesn't define any columns or anything, since those wouldn't be inherited, per Ian's discussions on subclassing SO. I *believe* that using transactions would be as simple as an uncomment and beginning to use trans.commit() . This might not be the case. It's also the case that I don't call any SOs in any __init__, and don't leave them hanging around. Some are called in awake, and some in buildTemplate, etc (I use tplCompiler as well), so it seems to me that I'm not getting any caching at all, due to lack of reuse during development. However, I believe that having all my SQLObjects inherit from DBObject, above, does give me pooling during a request. If I wrong, I hope someone corrects me as I spread disinformation. :) -- Randall Randall <ra...@ra...> "When you advocate any government action, you must first believe that violence is the best answer to the question at hand." -- Allen Thornton |