[Zope] Re: Conditional import of annotations for Zope 2.9 and 2.10:
how?
Maurits van Rees
m.van.rees at zestsoftware.nl
Mon May 14 10:11:20 EDT 2007
Raphael Ritz, on 2007-05-14:
> More a workaround than a solution but have you tried
> doing it the "new way" (Zope-2.10) and introducing
> backwards compatibility via a module alias to make
> zope.annotations also available as zope.app.annotations?
Ah, that might work yes.
Hm, I had problems getting it to work, and I think I have it the other
way around than what you said. The python code and the zcml only use
zope.annotation now and I make sure that in 2.9 zope.app.annotation is
available under the module name zope.annotation.
And I need to do the same for zope.(app.)annotation.interfaces,
otherwise problems still remain. So I now have the following in my
__init__.py:
try:
import zope.annotation
except ImportError:
# BBB for Zope 2.9
import zope.app.annotation
import zope.app.annotation.interfaces
import sys
sys.modules['zope.annotation'] = zope.app.annotation
sys.modules['zope.annotation.interfaces'] = zope.app.annotation.interfaces
Then it works. Thanks!
If someone knows a better way to do this with some condition in zcml
(not the ones that failed for me in the original message) then that
would still be appreciated.
BTW, for the python code a conditional import is not even really
necessary: in zope 2.10 (or 3.3) you simply get a DeprecationWarning
that zope.app.annotation will be removed in ope 3.5. But there is no
such deprecation for the zcml file: it has simply been removed.
Hm: for this reason it would be nice to still have the original zcml
file in there. Then including that zcml would still work though you
get a DeprecationWarning. Actually, that zcml file should then look
like this:
<configure
xmlns="http://namespaces.zope.org/zope">
<include package="zope.annotation" />
</configure>
That would work for me too: I just tried it. Should I propose this on
the zope 3 dev list? I do not currently read that list btw.
--
Maurits van Rees | http://maurits.vanrees.org/ [NL]
Work | http://zestsoftware.nl/
"Do not worry about your difficulties in computers,
I can assure you mine are still greater."
More information about the Zope
mailing list