Hash: SHA1

yuppie wrote:

> Tres Seaver wrote:
>> Log message for revision 94389:
>>   Move clashing imports into body of initialize().
>> Changed:
>>   U   Products.CMFDefault/trunk/Products/CMFDefault/__init__.py
> What are "clashing imports"? Can't they be fixed in an other way? I'd 
> prefer to have less code in initialize(), not more.

Importing anything at module scope in the __init__ can shadow the
"proper" import paths.  I would rather do *nothing* at import time, and
then do any necessary imports inside the 'initialize', i.e., as late as
possible.  An alternative would be to import 'initialize' itself from
another module.

> Maybe related:
> Running CMF trunk tests with Zope 2.10, I now get random test-module 
> import failures like this one:
>    Module: Products.CMFActionIcons.tests.test_exportimport
>    Traceback (most recent call last):
>      File "..\Products\CMFActionIcons\tests\test_exportimport.py", line 
> 24, in ?
>        from Products.CMFCore.testing import ExportImportZCMLLayer
>      File "..\Products\CMFCore\__init__.py", line 18, in ?
>        import PortalFolder
>      File "..\Products\CMFCore\PortalFolder.py", line 26, in ?
>        from App.class_init import default__class_init__ as InitializeClass
>      File "..\lib\python\App\class_init.py", line 16, in ?
>        import AccessControl.Permission
>      File "..\lib\python\AccessControl\Permission.py", line 18, in ?
>        import string, Products, Globals
>      File "..\lib\python\Globals\__init__.py", line 23, in ?
>        import Acquisition, ComputedAttribute, App.PersistentExtra, os
>      File "..\lib\python\App\PersistentExtra.py", line 24, in ?
>        from class_init import default__class_init__
>    ImportError: cannot import name default__class_init__
> Digging a bit deeper, I found a circular import in Zope that causes 
> these failures:

My bad:  I hadn't tested with non-trunk Zopes.  We might get away with
saying that CMF 2.2 requires at least Zope 2.11, but I think they would
break there too.

> AccessControl.Permission uses ApplicationDefaultPermissions defined in 
> App.class_init and App.class_init imports AccessControl.Permission.
> AFAICS moving ApplicationDefaultPermissions to AccessControl.Permission 
> would be the best way to fix this.

Yes, there is a bunch of stuff in App which doesn't belong there.
Unmasking it (by ripping out the imports from Globals) was a first step
to moving it into the right location.

- --
Tres Seaver          +1 540-429-0999          tsea...@palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org


Zope-CMF maillist  -  Zope-CMF@lists.zope.org

See https://bugs.launchpad.net/zope-cmf/ for bug reports and feature requests

Reply via email to