[ZODB-Dev] Re: Using Ape to map zclass property sheets

Shane Hathaway shane at zope.com
Tue May 13 13:21:35 EDT 2003


Rocky Burt wrote:
>     # classes_makeup contains information on folderish zclasses
>     folder_items_serializer = apeOfsserial.FolderItemsByKeychain()
>     folder_items_gw = apeStructure.SQLFolderItems(conn)
>     base_p_ser = root_mapper.getSubMapper('base_p').getSerializer()
>     base_p = root_mapper.getSubMapper('base_p').getGateway()
>     cfr = root_mapper.getClassifier()
>     for class_name, class_value in classes_makeup.items():
>         log('registered meta_type [%s]' % class_name)

This code logs before the actual work gets done.  If an error is being 
masked, the log will be incorrect.

>         m = root_mapper.addSubMapper(class_name)
>         cs = apeSerializers.AnyObjectSerializer(base_p_ser)
>         cs.addSerializer('items', folder_items_serializer)
>         m.setSerializer(cs)
>         cfr.register(class_name, class_name)
>         
>         g = apeGateways.CompositeGateway(base_p)
>         g.addGateway('items', folder_items_gw)
>         root_mapper.getSubMapper(class_name).setGateway(g)
> 
>         cs.addSerializer('propertysheets', folder_items_serializer)
>         g.addGateway('propertysheets', folder_items_gw)

Property sheets aren't folder items.  You need a serializer that knows 
about the "propertysheets" attribute.  This code will only use the 
"propertysheets" serializer/gateway if the ZClass instance is folderish 
and has items in the folder.

> Anychance someone can point out something that I'm blatantly doing
> wrong?

Meaning me? ;-)

Shane




More information about the ZODB-Dev mailing list