[Zope-dev] A suggestion for changing exception handler when loading 'c' optimisations to make modules more friendly for GAE

Jim Fulton jim at zope.com
Fri Jul 3 06:04:06 EDT 2009


On Jul 2, 2009, at 8:39 PM, Tim Hoffman wrote:

> Hi all
>
> Can I make a suggestion that would make a couple of modules more gae
> friendly ;-)
> zope.interface and zope.i18nmessageid have 'c' optimisations which
> obviously don't work under app engine.
>
>
> When these modules are imported you get the following exception.
>
> gae/1.333250465889549129/zope/i18nmessageid/ 
> _zope_i18nmessageid_message.py",
> line 6, in __bootstrap__
>    imp.load_dynamic(__name__,__file__)
>  File "/base/python_dist/lib/python2.5/py_imp.py", line 116, in  
> load_dynamic
>    raise NotImplementedError('This function is not supported on App  
> Engine.')

This bootstrapping code is generated by setuptools to deal with  
loading extension modules in zip files. It does some unholy things to  
make this work.  I'd really like to find a way to suppress this.

In general, I find deploying as zip files to be an anti-feature.  In  
seems especially insane when extension modules are involved.

> Unfortunately the code (in this case in zope.i18nmessageid.Message)
> does the following which doesn't deal with the Exception
> raised by the app engine runtime.

You mean with the exception raised by the setuptools wrapper code.

> try:
>    from _zope_i18nmessageid_message import Message
> except ImportError:
>    pass
>
> To make it more "gae friendly" I think we should change these  
> occurrences to
>
> try:
>    from _zope_i18nmessageid_message import Message
> except ImportError, NotImplementedError:
>    pass


This might be an ok work around.

How hard would it be to just remove the wrapper script when deploying  
to app engine?

Jim

--
Jim Fulton
Zope Corporation




More information about the Zope-Dev mailing list