#253 — "ImportError: cannot import name permissions" if anything imports Products.LinguaPlone before Products.ATContentTypes
by
Ross Patterson
—
last modified
Oct 06, 2010 12:12 PM
| State | Resolved |
|---|---|
| Version: | 4.x |
| Area | Functionality |
| Issue type | Bug |
| Severity | Medium |
| Submitted by | Ross Patterson |
| Submitted on | Aug 19, 2010 |
| Responsible | Hanno Schlichting |
| Target release: | 4.x |
Under Plone 4 and LinguaPlone 4.0a1, something happens in the OFS.Application.import_products importing such that if anything imports Products.Archetypes.atapi (or I suspect anything that results in importing Products.LinguaPlone when installed) before Products.ATContentTypes, then when OFS.Application.import_products imports Products.LinguaPlone it results in the following error and traceback:
Traceback (most recent call last):
File "/usr/local/lib/python/site-packages/Zope2-2.12.10-py2.6-linux-i686.egg/Zope2/Startup/run.py", line 56, in <module>
run()
File "/usr/local/lib/python/site-packages/Zope2-2.12.10-py2.6-linux-i686.egg/Zope2/Startup/run.py", line 21, in run
starter.prepare()
File "/usr/local/lib/python/site-packages/Zope2-2.12.10-py2.6-linux-i686.egg/Zope2/Startup/__init__.py", line 87, in prepare
self.startZope()
File "/usr/local/lib/python/site-packages/Zope2-2.12.10-py2.6-linux-i686.egg/Zope2/Startup/__init__.py", line 264, in startZope
Zope2.startup()
File "/usr/local/lib/python/site-packages/Zope2-2.12.10-py2.6-linux-i686.egg/Zope2/__init__.py", line 47, in startup
_startup()
File "/usr/local/lib/python/site-packages/Zope2-2.12.10-py2.6-linux-i686.egg/Zope2/App/startup.py", line 57, in startup
OFS.Application.import_products()
File "/usr/local/lib/python/site-packages/Zope2-2.12.10-py2.6-linux-i686.egg/OFS/Application.py", line 574, in import_products
return done.keys()
File "/usr/local/lib/python/site-packages/Zope2-2.12.10-py2.6-linux-i686.egg/OFS/Application.py", line 597, in import_product
if hasattr(product, '__module_aliases__'):
File "/usr/local/lib/python/site-packages/Products.LinguaPlone-4.0a1-py2.6.egg/Products/LinguaPlone/__init__.py", line 3, in <module>
from Products.LinguaPlone import permissions
ImportError: cannot import name permissions
This does not happen under Plone 3 with LinguaPlone 3.1, or under Plone 4 when LinguaPlone is not included. I also intercepted the ordering of the products in OFS.Application.get_products to manually place ATBackRef *after* ATContentTypes and it worked fine. As such the issue is specific to the combination of Plone 4, LinguaPlone, and any Product whose name is alphabetically sorted before ATContentTypes.
Traceback (most recent call last):
File "/usr/local/lib/python/site-packages/Zope2-2.12.10-py2.6-linux-i686.egg/Zope2/Startup/run.py", line 56, in <module>
run()
File "/usr/local/lib/python/site-packages/Zope2-2.12.10-py2.6-linux-i686.egg/Zope2/Startup/run.py", line 21, in run
starter.prepare()
File "/usr/local/lib/python/site-packages/Zope2-2.12.10-py2.6-linux-i686.egg/Zope2/Startup/__init__.py", line 87, in prepare
self.startZope()
File "/usr/local/lib/python/site-packages/Zope2-2.12.10-py2.6-linux-i686.egg/Zope2/Startup/__init__.py", line 264, in startZope
Zope2.startup()
File "/usr/local/lib/python/site-packages/Zope2-2.12.10-py2.6-linux-i686.egg/Zope2/__init__.py", line 47, in startup
_startup()
File "/usr/local/lib/python/site-packages/Zope2-2.12.10-py2.6-linux-i686.egg/Zope2/App/startup.py", line 57, in startup
OFS.Application.import_products()
File "/usr/local/lib/python/site-packages/Zope2-2.12.10-py2.6-linux-i686.egg/OFS/Application.py", line 574, in import_products
return done.keys()
File "/usr/local/lib/python/site-packages/Zope2-2.12.10-py2.6-linux-i686.egg/OFS/Application.py", line 597, in import_product
if hasattr(product, '__module_aliases__'):
File "/usr/local/lib/python/site-packages/Products.LinguaPlone-4.0a1-py2.6.egg/Products/LinguaPlone/__init__.py", line 3, in <module>
from Products.LinguaPlone import permissions
ImportError: cannot import name permissions
This does not happen under Plone 3 with LinguaPlone 3.1, or under Plone 4 when LinguaPlone is not included. I also intercepted the ordering of the products in OFS.Application.get_products to manually place ATBackRef *after* ATContentTypes and it worked fine. As such the issue is specific to the combination of Plone 4, LinguaPlone, and any Product whose name is alphabetically sorted before ATContentTypes.
- Steps to reproduce:
- 1. Start with a Plone 4.0RC1 buildout
2. Add LinguaPlone 4.0a1
3. Add a Product whose name is sorted before ATContentTypes, such as the Plone 4 compatible version of ATBackRef from https://svn.plone.org/[…]/trunk@13013
4. Statup the instance with "bin/instance1 fg" and note the error1
Added by
Ross Patterson
on
Aug 19, 2010 10:23 PM
I did some examining of the module level globals at various points and couldn't find any name conflicts so I'm at a loss what to do about this. Unfortunately, this is holding up upgrading a client to Plone 4. :(
Added by
Ross Patterson
on
Aug 19, 2010 10:34 PM
Just found a workaround, if I import Products.ATContentTypes in ATBackRef/__init__.py before anything else then everything works just fine. This is a kludge and the underlying problem somewhere between ATCT and LinguaPlone should still be fixed. I've committed this workaround to ATBackRef (https://dev.plone.org/archetypes/changeset/13014) so for reproducing the issue, use the previous revision, r13013.
Added by
Mikko Ohtamaa
on
Sep 09, 2010 01:26 PM
I can also trigger this bug on Plone + LinguaPlone 3.1/4.0 using a different code path from a custom theme::File "/home/moo/code/finnmall/finnmall/eggs/zope.configuration-3.6.0-py2.6.egg/zope/configuration/config.py", line 180, in resolve
mod = __import__(mname, *_import_chickens)
File "/home/moo/code/finnmall/finnmall/src/abita.theme/abita/theme/browser/viewlets/selector.py", line 12, in <module>
from Products.LinguaPlone.interfaces import ITranslatable
File "/home/moo/code/finnmall/finnmall/eggs/Products.LinguaPlone-3.1-py2.6.egg/Products/LinguaPlone/__init__.py", line 3, in <module>
from Products.LinguaPlone import permissions
ZopeXMLConfigurationError: File "/home/moo/code/finnmall/finnmall/parts/instance/etc/site.zcml", line 15.2-15.55
ZopeXMLConfigurationError: File "/home/moo/code/finnmall/finnmall/parts/instance/etc/package-includes/001-abita.policy-configure.zcml", line 1.0-1.56
ZopeXMLConfigurationError: File "/home/moo/code/finnmall/finnmall/src/abita.policy/abita/policy/configure.zcml", line 8.4-8.37
ZopeXMLConfigurationError: File "/home/moo/code/finnmall/finnmall/src/abita.theme/abita/theme/configure.zcml", line 9.2-9.32
ZopeXMLConfigurationError: File "/home/moo/code/finnmall/finnmall/src/abita.theme/abita/theme/browser/configure.zcml", line 10.2-10.33
ZopeXMLConfigurationError: File "/home/moo/code/finnmall/finnmall/src/abita.theme/abita/theme/browser/viewlets/configure.zcml", line 6.2-11.6
ImportError: cannot import name permissions
Added by
Hanno Schlichting
on
Oct 06, 2010 09:21 AM
We have seen this in an internal project of ours as well.
Issue state:
Unconfirmed
→
Confirmed
Responsible manager:
(UNASSIGNED)
→
hannosch
Target release:
None
→
4.x
Added by
Hanno Schlichting
on
Oct 06, 2010 09:28 AM
Fixed in SVN, will be part of the 4.0a4 release.
Issue state:
Confirmed
→
Resolved
Added by
Patrick Gerken
on
Oct 06, 2010 12:12 PM
I noticed that change after it broke some things.I had similar problems and fixed these in ATContenttypes, by not using imports to test if a package exists, that often triggers the problems described here.
This is my change:
http://dev.plone.org/collec[…]ucts.ATContentTypes%2Ftrunk
And this a short description
http://do3cc.blogspot.com/[…]/dont-catch-import-errors-use.html
No responses can be added.
If you can, please log in before submitting a reaction.
