[z3-five] Wrapping Z2 interfaces (maybe, "bride of Frankenzope"?)
Tres Seaver
tseaver at zope.com
Mon Aug 2 17:20:30 MEST 2004
Martijn Faassen wrote:
> Tres Seaver wrote:
>
>> For existing Zope2 applications which already declare and use Zope2
>> interfaces, it seems natural to re-use those specifications. I have a
>> utility module (with a handful of tests) which exports
>> 'fromZ2Interface', a function which introspects a Zope2 interface
>> object and synthesizes an "equivalent" Zope 3 interface.
>
>
> Sounds like a useful thing to me. Interesting!
>
>> I am currently using it in a scratch product, CMFonFive,
>
>
> Very interesting name, that. :)
>
>> to populate the 'interfaces' module, e.g.:
>>
>> from utilities import fromZ2Interface
>>
>> from Products.CMFCore.interfaces.CachingPolicyManager \
>> import CachingPolicyManager as _IZ2_CachingPolicyManager
>>
>> ICachingPolicyManager = fromZ2Interface(_IZ2_CachingPolicyManager)
>>
>> del _IZ2_CachingPolicyManager
>>
>>
>> The amount of noisy boilerplate in that module is painful: I did take
>> the opportunity to rename CMF interfaces, but that is the only real
>> "value" the module adds. I am pondering a ZCML directive which would
>> remove the need for the boilerplate; something like:
>>
>> <five:bolt-on
>>
>> source="Products.CMFCore.interfaces.CachingPolicyManager.CachingPolicyManager"
>>
>> target=".interfaces.ICachingPolicyManager"
>> />
>>
>> Would the utility be useful in Five? The directive?
>
>
> Yes, sounds like a good idea! Just to be clear, this would be a utility
> as in 'utility module', not as in "Zope 3 utility" right? A module is
> definitely a bit easier to integrate. Z3 utilities I think work (at
> least global ones), but we haven't done a lot of testing.
Right. It is literally called 'utilities.py' in 'CMFonFive'.
> I'd suggest another name for the directive though. Hm, perhaps
> five:convert-interface
>
> <five:convert-interface
>
> zope2="Products.CMFCore.interfaces.CachingPolicyManager.CachingPolicyManager"
>
> zope3=".interfaces.ICachingPolicyManager"
> />
>
> I'm not sure about the zope2 and zope3 attributes, though that would
> make it fairly clear what we're dealing with.
>
> Or perhaps we could call it five:bride :).
Heh, that was the first spelling I played with. ;) I don't have any
investment in how it is spelled. I will prototype it using your spelling.
I will ask for SVN access on IRC.
Tres.
--
===============================================================
Tres Seaver tseaver at zope.com
Zope Corporation "Zope Dealers" http://www.zope.com
More information about the z3-five
mailing list