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)
    def __exportNode(self):
        return self._exportNode()
    def __importNode(self, *args)
    node = property(__exportNode, __importNode)
To allow proper subclass overriding and avoid the dead chicken of having to redefine the node property each time.
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...

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.



Zope-CMF maillist  -  Zope-CMF@lists.zope.org

See http://collector.zope.org/CMF for bug reports and feature requests

Reply via email to