<div class="gmail_quote">2009/9/14 wsh <span dir="ltr"><<a href="mailto:shuhao.w@gmail.com">shuhao.w@gmail.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi, all<br>
<br>
When I'm testing a package, some code is broken and I get the error<br>
message "AttributeError: 'module' object has no attribute<br>
'interfaces'".<br>
<br>
After I checked the code I found that there are some code in the<br>
__init__.py like following:<br>
<br>
>>> from zope.app import container<br>
<br>
When it try to reference the interfaces attribute of the container<br>
module, but the attribute does not exist. I checked the container with<br>
print dir(container) and get following:<br>
<br>
['__builtins__', '__doc__', '__file__', '__name__', '__path__']<br>
<br>
<br>
But if I add following line in the __init__.py this problem can be<br>
solved.<br>
<br>
>>> from zope.app import container<br>
>>> import zope.app.container.constraints<br>
>>> print dir(container)<br>
['__builtins__', '__doc__', '__file__', '__name__', '__path__',<br>
'constraints', 'i18n', 'interfaces']<br>
<br>
<br>
<br>
Can anyone explain this?<br></blockquote><div><br>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.<br>
</div></div><br>-- <br>WBR, Dan Korostelev<br>