[z3-five] Wrapping Z2 interfaces (maybe, "bride of Frankenzope"?)
Martijn Faassen
faassen at infrae.com
Mon Aug 2 16:58:21 MEST 2004
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.
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 :).
Regards,
Martijn
More information about the z3-five
mailing list