zope.testbrowser is swallowing imports that confuse you with: TypeError: Error when calling the metaclass bases
Affects | Status | Importance | Assigned to | Milestone | ||
---|---|---|---|---|---|---|
Zope 3 | Status tracked in 3.4 | |||||
3.4 |
Fix Released
|
Undecided
|
Christian Theune |
Bug Description
[Hi benji]
in zope.testbrowse
try:
from zope import interface, schema
except ImportError:
from dummymodule import interface, schema
This creates a very confusing situation if one has zope.interface installed but not zope.schema. In this case, zope.interface is set to dummymodule.
Traceback (most recent call last):
...
File "/Users/
from zope.testbrowse
File "/Library/
class Browser(
File "/opt/local/
return callback(newClass)
File "/opt/local/
classImplem
File "/opt/local/
spec.declared += tuple(_
File "/opt/local/
_normalizea
File "/opt/local/
for v in sequence:
TypeError: Error when calling the metaclass bases
iteration over non-sequence
The cause is simply that IBrowser is not a descendent of Interface. Doh! That could be explained a little nicer in zope.interface IMHO although there is some recursion that needs to be preserved and it makes my head hurt.
_
In zope.testbrowser I think the best fix for this is to make both of these modules (zope.interface and zope.schema) requirements. I took a stab at simply breaking up the "from zope import interface, schema" so that it imports the dummy interface only for schema but this creates another exception "invalid interface" since the schema calls used to build IBrowser are dummy objects. I suggest biting the bullet and requiring installation of both. Or you could use pkg_resources in the setup file to raise an error if one is installed but not the other.
The change for making them required is the easier route, here is a patch:
Index: src/zope/
=======
--- src/zope/
+++ src/zope/
@@ -26,10 +26,7 @@
import time
import urllib2
-try:
- from zope import interface
-except ImportError:
- from dummymodules import interface
+from zope import interface
RegexType = type(re.
_compress_re = re.compile(r"\s+")
Index: src/zope/
=======
--- src/zope/
+++ src/zope/
@@ -17,11 +17,7 @@
"""
__docformat__ = "reStructuredText"
-try:
- # zope.interface and zope.schema aren't included in the stand-alone version
- from zope import interface, schema
-except ImportError:
- from dummymodules import interface, schema
+from zope import interface, schema
class IBrowser(
Index: setup.py
=======
--- setup.py (revision 80664)
+++ setup.py (working copy)
@@ -48,11 +48,11 @@
tests_require = ['zope.testing'],
install_
- 'ClientForm'],
+ 'ClientForm',
+ 'zope.interface',
+ 'zope.schema'],
extras_require = dict(
- test = ['zope.interface',
- 'zope.schema',
- 'zope.app.
+ test = ['zope.
Changed in zope3: | |
assignee: | nobody → benji-york |
status: | New → Fix Committed |
somehow I also felt compelled to submit a patch to address this in zope.interface : https:/ /bugs.launchpad .net/zope3/ +bug/149544
...hey, it's Friday and I don't feel like doing any real work :)