[Zope-CMF] Re: GenericSetup improvements

Florent Guillaume fg at nuxeo.com
Thu Dec 29 12:39:34 EST 2005


On 27 Dec 2005, at 10:51, yuppie wrote:
> Florent Guillaume wrote:
>> Here's a few things I'd like to change in GenericSetup's  
>> management of properties (PropertyManagerHelper):
>> - not export read-only properties,
>> - not purge read-only properties,
>
> +1 (these are bugs that need to be fixed)

Done.

>> Also I'd like to change things like:
>>     node = property(_exportNode, _importNode)
>> into:
>>     def __exportNode(self):
>>         return self._exportNode()
>>     def __importNode(self, *args)
>>         self._importNode(*args)
>>     node = property(__exportNode, __importNode)
>> To allow proper subclass overriding and avoid the dead chicken of  
>> having to redefine the node property each time.

Done.

But in my (complex) setup it revealed an unintended side effect.  
There are actually 3 useful methods when doing export (also valid for  
import):

- export as simple node for its parent file (just the <object  
name="foo" meta_type="bar"> part),
- export as full node tree,
- export as XML body using the "full node" code.

Before, the fact that you defined or not
    node = property(_exportNode, _importNode)
made the export "do the right thing", as
  - _extractObjects calls exporter.node, thus calls the last node  
property defined, whereas
  - _exportBody calls self._exportNode(), thus inherits

This is *very* implicit and magic, and would benefit from some  
refactoring...

The current status of the code is that exports of more that one level  
are currently not correct.
It seems there's no unit test for it...
I'll fix this in a few days unless someone is interested to do it  
before then.

I propose to have _exportSimpleNode for the basic version,  
_exportNode for the full version, and have _extractObjects call  
_exportSimpleNode and _exportBody call _exportNode. The node property  
would refer to the full version.

Moreover, I propose to *deprecate* the .node and .body properties, I  
don't see how they help readability and having properties do complex  
work is really not intuitive to me. They're doing more harm than  
anything else (anytime I read the code I have to scratch my head and  
remember that it's not just an attribute assignment).

Florent

-- 
Florent Guillaume, Nuxeo (Paris, France)   Director of R&D
+33 1 40 33 71 59   http://nuxeo.com   fg at nuxeo.com




More information about the Zope-CMF mailing list