[ZODB-Dev] AdaptableStorage and ZClass instances

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


Roch=E9 Compaan wrote:
> I think object relational mappings are very implementation specific so =
I
> don't expect the mapper to do all the magic. AdaptableStorage can help
> do the 70% of work that is common in all implemenations.
>=20
> What I think will work much better and really improve queryability of
> data is if one uses a table per class map. One shouldn't require a
> gateway per class however - that's to much work ;-) A single gateway
> can generate sql for most classes based simply on class properties.
> What will help here is if one has typemap per RDBMS, mapping python
> datatypes to the RDBMS' datatypes. For more complex types one will need
> specialised gateways but that is to be expected.
>=20
> If this idea have appeal - I have some code that inspects class schema
> and generates sql from it. I'll see if I can make some time this weeken=
d
> to make it work with AS.

Yes, it sounds very interesting.  One thing to keep in mind is that when=20
loading and storing objects, gateways don't have access to the object=20
being serialized/deserialized.  This separation is designed to encourage=20
reuse and make integration with distributed object systems like ZEO=20
feasible.

However, at configuration time, you have access to the classes of the=20
objects to be loaded/stored.  During configuration, you could take the=20
opportunity to automatically configure mappers and gateways based on=20
class inspection.  Application code might look very much like the=20
SQLObject example (see Christian's post), except that classes would use=20
ZODB.Persistent as a base class (rather than SQLObject) and the same=20
code would work in regular ZODB.

Shane