[DB-SIG] db-api suggestions / zike data classes

Brad Clements bkc@murkworks.com
Tue, 18 Apr 2000 10:02:10 -0500

On 18 Apr 2000, at 9:43, Andy Dustman wrote:

> On Tue, 18 Apr 2000, Brad Clements wrote:
> > I've been using SQLDict for a week and I say, it is a really nice peice
> > of work.
> > 
> > I'm using it with Zope.
> ? Zope is one of the last places I would expect to see SQLDict, due to
> Zope's own DA interface, but hey, if it works for you...

Yes, Zope has a nice DA interface, but I wanted to be able to build and 
test the object logic outside of Zope, but be able to use the same code 
within Zope without changing anything.

Zope DAs are nice, but they don't work like a DB-API module. 

I didn't want to code the business logic in DTML, its not really meant for 
that. On the other hand, I didn't want to put the logic in a Python 
extension just to have all the database code in Zope, because the logic 
part wouldn't have database access without explicitely passing around a 
Zope DA or SQL Method. This would tie me to Zope too much, and I'd 
be unable to work on the logic outside of Zope.

> > Some mods I've made to SQLDict:
> > 
> > 1. Added __getitem__ support to SQLDict, and Table items to make 
> > lookup easier from Zope.
> <scratches head> I think I know what you mean. There's a tendency to set a
> lot of new attributes in a SQLDict objects, i.e. one of the examples is:
> >>> db.People = db.Table('PEOPLE', [ 'Name', 'Address', 'City', 'State' ])
> For that matter, if you use ObjectBuilder and register() the class with the
> database, it will similarly create attributes within the SQLDict object.

Exactly.  Since table points to db, and now db points to the created 
table, you have a circular reference.

To break this, I'd have to do db.People = None, in which case I have to 
keep track of all the tables I've added to db.

db._delete() does the deletion for me.

> Hold on here... Before you start ripping stuff out and putting them into
> separate classes, send me patches. I haven't done hardly any development on
> SQLDict in more than a year. Last thing I did was through in a MySQLDict
> subclass because I needed it. So it would probably benefit from some fresh
> ideas. And some of these sound pretty good. 

I'll send it to you. Some of the changes are not as 'pythonic' as your 
code, but I'm still learning.

Brad Clements,                bkc@murkworks.com   (315)268-1000
http://www.murkworks.com                          (315)268-9812 Fax
netmeeting: ils://ils.murkworks.com               AOL-IM: BKClements