[Zope3-Users] zope.app.container importing problem

Dan Korostelev nadako at gmail.com
Mon Sep 14 13:05:07 EDT 2009


2009/9/14 wsh <shuhao.w at gmail.com>

> Hi, all
>
> When I'm testing a package, some code is broken and I get the error
> message "AttributeError: 'module' object has no attribute
> 'interfaces'".
>
> After I checked the code I found that there are some code in the
> __init__.py like following:
>
>   >>> from zope.app import container
>
> When it try to reference the interfaces attribute of the container
> module, but the attribute does not exist. I checked the container with
> print dir(container) and get following:
>
>   ['__builtins__', '__doc__', '__file__', '__name__', '__path__']
>
>
> But if I add following line in the __init__.py this problem can be
> solved.
>
>    >>> from zope.app import container
>    >>> import zope.app.container.constraints
>    >>> print dir(container)
>    ['__builtins__', '__doc__', '__file__', '__name__', '__path__',
> 'constraints', 'i18n', 'interfaces']
>
>
>
> Can anyone explain this?
>

That's because zope.app.container.interfaces module is not imported, so
zope.app.container doesn't have "interfaces" attribute. But it seems to be
imported by "constraints" module, so it magically appears as "interfaces" in
zope.app.container.


-- 
WBR, Dan Korostelev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zope3-users/attachments/20090914/b93a369c/attachment.html 


More information about the Zope3-users mailing list