Thread: [SQLObject] SQLObject / FireBird / WebWare
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Ian S. <ia...@et...> - 2003-09-25 22:01:00
|
General questions : How do SQLObject models fit into Webware? Are there threading issues? Does it work like dbPool? If anyone has some simple (even pseudocode) examples that would be a great help. Thanks. |
From: Randall R. <ra...@ra...> - 2003-09-26 00:31:14
|
On Thursday, September 25, 2003, at 05:49 PM, Ian Sparks wrote: > General questions : > > How do SQLObject models fit into Webware? > Are there threading issues? > Does it work like dbPool? > > If anyone has some simple (even pseudocode) examples that would be a > great > help. Well, I haven't run into any big issues yet, and I've been building my latest app (a combination articles site and shopping cart) with it. On the other hand, I'm not trying to store my servlets in the db or anything. I also haven't needed transactions yet, but expect to. The two easy ways of getting around the caching (when updating articles, etc) are creating any needed objects in awake() and destroying them in sleep(), or just restarting the appserver on changes that would be cached by a servlet. I do the latter. For me, SQLObject has replaced the pooling built into psycopg. Just in time, too, as psycopg 2.0 will not have it anymore. :) If you can be more specific about something you'd like to see an example of, I can just pull out some of my current code (assuming I'm doing whatever you want to see). -- 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 |
From: Ian S. <ian...@et...> - 2003-09-29 13:46:20
|
"Randall Randall" <ra...@ra...> wrote in message news:B6C...@ra...... > If you can be more specific about something you'd like > to see an example of, I can just pull out some of my > current code (assuming I'm doing whatever you want to > see). I'm guessing that something like : #mypage.py: from WebKit.Page import Page import MySOClasses 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? Thanks. |
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 |