[Zope3-dev] Removing hard dependency from zope.i18nmessageid
C extension
Jim Fulton
jim at zope.com
Wed Feb 9 07:37:29 EST 2005
Christian Heimes wrote:
> Hi folks!
>
> With the new i18nmessageid c module in zope.i18nmessageid it is no
> longer possible to use zope.schema and zope.i18n w/o a c extensions.
> Although zope.interface has an optimized module in c like
> zope.i18nmessageid there is also a python only implementation.
>
> I would like to see such a python only implementation in
> zope.i18nmessageid, too.
Agreed. As a general principal, we should have C and Python
versions of things.
> Hey as far as I can see there *is* already a
> python only implementation in zope.i18nmessageid.messageid. :) I know
> it's going to be removed in ZopeX3.2 but as long we have it can we
> please change the zope.i18nmessageid package like I propose?
>
> old:
> from messageid import MessageID, MessageIDFactory
> from message import Message, MessageFactory
>
> my proposal:
> from messageid import MessageID, MessageIDFactory
> try:
> from _zope_i18nmessageid_message import Message
> except ImportError:
> # c optimization not availabel
> Message = MessageID
> MessageFactory = MessageIDFactory
> else:
> from message import Message, MessageFactory
You need to be more careful:
1. I'm 90% sure that the Python and C versions have
different APIs. If this is so, then you need to
create a new Python implementation with the same
api as the C version.
2. If message ids are picklable, then you need to arrange
for the Python and C versions to have the same module
and class names. In fact, you need to make sure that
they have compatible pickles.
Jim
--
Jim Fulton mailto:jim at zope.com Python Powered!
CTO (540) 361-1714 http://www.python.org
Zope Corporation http://www.zope.com http://www.zope.org
More information about the Zope3-dev
mailing list