[ZODB-Dev] Ape and ConflictError's

Shane Hathaway shane at zope.com
Wed Apr 30 16:12:21 EDT 2003


Rocky Burt wrote:
> Well, I guess the issue with me is that I've read your docs on what
> serializers/mappers/etc is (in doc/outline.txt) and things are beginning
> to make sense.  But what I'd like to know now is exact steps in setting
> up a new mapping (what code pieces do what).
> 
> Reason for this is because reading through sqlmapper.py and
> basemapper.py it looks like you're almost duplicating stuff.  Except
> that sqlmapper just sets up mappers whereas basemapper sets up
> serializers?

I see what you mean now.  This part isn't quite finished.

basemapper creates the mappers with no gateways.  sqlmapper adds the 
gateways.  Both modules are begging to be rewritten in XML, I think. 
But I didn't want to come up with an XML schema until I had a good 
motivation and I knew what the configuration would be like.  Making it 
easier for people to put together custom mappers is a strong motivation, 
and the configurability is almost clear, so I plan to write an XML 
schema soon.

> I guess a better example is this...
> 
> Lets say I have new class A with meta_type of 'A_meta_type'.  Class A
> has an attribute called myNewUniqueAttributeB which will always be an
> instance of class B.  What code exactly would you use to hook that in so
> it doesn't go into the remainder table?

I would write a function that calls sqlmapper.createMapper() then 
modifies the generated mapper.  The function would add two mappers to 
the root mapper (one mapper per class.)  The function would assign a 
serializer and gateway to each mapper.  Then the function would tell the 
root classifier to use the new mappers when it encounters A_meta_type 
and B_meta_type instances.

Once this is done in XML, though, I hope it will be much more natural: 
you'll copy a sample configuration into an XML file in your own Zope 
product, change the XML to match your needs, and activate the new 
configuration.  Instead of learning lots of gory details, most people 
will only have to write serializers, gateways, and configuration files.

> ps. I'm also in the process of reading Martin Fowler's, "Patterns of
> Enterprise Application Architecture".

I wish the book were still up on the web.  At least there are skeletal 
remains.

Shane




More information about the ZODB-Dev mailing list