[ZODB-Dev] AdaptableStorage and ZClass instances

Roché Compaan roche@upfrontsystems.co.za
Fri, 14 Feb 2003 11:01:00 +0200


On Thu, 13 Feb 2003 15:47:38 -0500
Shane Hathaway <shane@zope.com> wrote:

> However, at configuration time, you have access to the classes of the 
> objects to be loaded/stored.  During configuration, you could take the 
> opportunity to automatically configure mappers and gateways based on 
> class inspection.

Can I only access the class at configuration time? Can't one
get access to the class at runtime through the MetaTypeClassifier?

> Application code might look very much like the 
> SQLObject example (see Christian's post), except that classes would use 
> ZODB.Persistent as a base class (rather than SQLObject) and the same 
> code would work in regular ZODB.

Mmm, I don't know if I want to put any storage specific details in my
application code just to make the OR Mapping work. What I think is
genius about AS is that I can keep writing apps in the way I'm used to
and in a way that fits the framework iow I don't have to subclass from
this or that to persist my classes. I'd rather do more work on the side
of the OR mapper and teach it how to persist objects in my problem
domain.

For a start one can definitely have a SQL base class that implements
basic load and store methods which leaves you with only having to
specify sql strings in the subclass, like Rocky suggested.

But then one still has to write SQL for each class that you want to
persist. My idea was to have a default properties gateway that generates
SQL at runtime for all classes that doesn't have a specific gateway.
This seems problematic if one doesn't have access to the object and
since this is a default gateway one wouldn't now anything about the
class either. All one really needs is the classname and the property
types and values on the object.  Is this at all possible?  The classname
can then be used in the load and store methods of the gateway to query
the right table and property types will be looked up in a typemap for 
the RDBMS.


-- 
Roché Compaan
Upfront Systems                 http://www.upfrontsystems.co.za