[Zope-CMF] Re: [CMF 2.1] FSPageTemplate & Unicode

Philipp von Weitershausen philipp at weitershausen.de
Mon Jan 8 17:46:46 EST 2007


Martin Aspeli wrote:
> Dieter Maurer wrote:
>> Martin Aspeli wrote at 2007-1-7 23:40 +0000:
>>> ...
>>> Why not do it a more Zope3 ish way:
>>>
>>> class ICMFTool(Interface):
>>>    """Marker for any CMF tool"""
>>>
>>> and then in the subclass of the local component registry:
>>>
>>> local_utility = ....
>>> if ICMFTool.providedBy(local_utility):
>>>     local_utility = local_utility.__of__(context)
>>>
>>> or so.
>>
>> No need to invent a new marker interface for this.
>>
>>   Objects ready to participate in context wrapping indicate this
>>   by the "__of__" method...
> 
> No, no need, but I'd argue good reasons.
> 
>  - It's an explicit declaration of support
>  - It's a lot less magic
>  - It's prettier than getattr/hasattr
>  - If something else has an __of__() for whatever reason, we don't catch 
> it by accident.
>  - It may not be desirable to wrap everything that *could* be wrapped.

Actually, I agree with Dieter here. If something has an __of__(), just 
wrap it. You can't possibly do anything wrong, actually, as it already 
happens and it provides the best backward compatibility with what we 
have right now.

Once we support __parent__ pointers, we can phase out the wrapping. We 
can do that by making less and less objects have those __of__() methods 
for example.


-- 
http://worldcookery.com -- Professional Zope documentation and training
2nd edition of Web Component Development with Zope 3 is now shipping!



More information about the Zope-CMF mailing list