[Zope-dev] Re: [z3-five] relocating Zope 2 core interfaces - a proposal

Philipp von Weitershausen philipp at weitershausen.de
Fri May 6 12:29:00 EDT 2005


yuppie wrote:
>> I don't think we need to break backward compatability. We would just 
>> need to deprecate the Five.interfaces location.
>>
>> Basically, the goals are:
>>
>> * The solution needs to work with Zope 2.7
>> * Preferrably, the interface import spelling should be equal on both
>>   systems (which means a monkey on 2.7 is probably inevitable).
>> * On 2.8 we want to have definitions of the z3-style interfaces in the
>>   Zope tree.
>> * Five.interfaces and OFS.interfaces.*, etc. need to contain
>>   the exact *same* interfaces (same, not equal) on both systems at all
>>   times.
> 
> 
> That's the point I missed!

It's important because if someone registers a view for 
Five.interfaces.IObjectManager and OFS.ObjectManager.ObjectManager 
implements OFS.interfaces.IObjectManager, you'd want these to be the same...

> So we just need code like this at the end of Five.interfaces:
> 
> try:
>     # override IObjectManager with Zope 2.8 interface
>     from OFS.interfaces import IObjectManager
> except ImportError:
>     # monkey patch Zope 2.7 OFS
>     ...
> 
> Right?

Yup, something like that. I'd prefer something like this, though::

   try:
       # override IObjectManager with Zope 2.8 interface
       from OFS.interfaces import IObjectManager
       def monkey():
           pass
   except ImportError:
       def monkey():
           # monkey patch Zope 2.7 OFS

and in Five.monkey, we do::

   from Products.Five.interfaces import monkey as interfaceMonkey
   interfaceMonkey()

That way all monkey are effectively executed from Five.monkey which is 
the convention. I do it like that on the philikon-i18n branch, too, if 
you want to see another example.

>> * Five.interfaces should be deprecated as an import location in the long
>>   term.
> 
> Fine. I no longer think we need to break backward compatibility.

Good :).

Philipp


More information about the Zope-Dev mailing list