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

Andy Dustman adustman@comstar.net
Tue, 18 Apr 2000 09:43:08 -0400 (EDT)


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...
 
> My problem was seperating "business logic" from presentation. I wanted 
> an object oriented interface to records, and a mechanism to 
> conveniently use those objects via the Web.
> 
> SQLDict has given me the former method. I'm working on my own 
> HTMLForm tools that works in conjunction with SQLDict based objects 
> to create basic forms and to represent one-to-one, many-to-one, many-
> to-many relationships.
> 
> I'd like to take a look at Andy's HyperText, but starship has been down 
> for a while now.

I've sent you a copy separately. If anyone else wants one, just let me
know.
 
> 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.

> 2. There is a circular reference problem when using the register() 
> method of ObjectBuilder. Tables point to SQLDict, and SQLDict points 
> to table, and Index points to Table and Table points to Index. I've added 
> a _delete() method to SQLDict, Table and Index to help break these 
> references.  
> 
> Its an ugly hack, I'm not sure how to do it nicer.
> 
> 3. Added onValidate(), onUpdate(), onCreate() dummy methods to 
> ObjectBuilder. I think onValidate() should go in my other Mix-in class, I'll 
> probably move it out of ObjectBuilder.
> 
> 4. Added an update(), refresh() and delete() method to ObjectBuilder
> 
> 5. set_keywords() can take an instance object.

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. 

-- 
andy dustman       |     programmer/analyst     |      comstar.net, inc.
telephone: 770.485.6025 / 706.549.7689 | icq: 32922760 | pgp: 0xc72f3f1d
"Therefore, sweet knights, if you may doubt your strength or courage, 
come no further, for death awaits you all, with nasty, big, pointy teeth!"