[Zope-CMF] Re: GenericSetup improvements

yuppie y.2005- at wcm-solutions.de
Fri Dec 30 08:51:13 EST 2005


Hi Florent!


Florent Guillaume wrote:
> On 29 Dec 2005, at 21:20, yuppie wrote:
>> Florent Guillaume wrote:
>>> On 27 Dec 2005, at 10:51, yuppie wrote:
>>>> Florent Guillaume wrote:
>>>>> 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.
>>
>> Correct.
>>
>>> 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...
>>
>> Well. That's the way property() works. Your change adds magic because 
>> it makes property() inherit its methods.
> 
> I know it's the way property works, but it's usually (and also by me) 
> considered a hindrance, because people are used to see methods inherited.

I agree, that's why I gave a +1 for your proposal. But on the other hand 
you can get used to that difference. I believe my code would look less 
implicit and magic to you if you would work with that difference instead 
of masking it with your code.

This seems to be a more general issue that accidentally came up in the 
context of setup adapters. Maybe we need a policy for using property() 
in CMF.

> I'll answer the rest of your email when I've thought more about this whole business :)

I hope the small checkin I made today is a step in the right direction.


Cheers,

	Yuppie



More information about the Zope-CMF mailing list