today I found a nice brain teaser. What is the outcome of the following:
>>> from zope.interface import Interface
>>> from zope.schema import TextLine
>>> class IFoo(Interface):
... title = TextLine()
>>> class IBar(IFoo):
<zope.schema._bootstrapfields.TextLine object at 0xb7bc17ac>
If you ask the zope.interface.interfaces.IAttribute documentation you get:
interface = Attribute('interface',
'Stores the interface instance in which the '
'attribute is located.')
In plain English: <InterfaceClass __main__.IFoo>
If you ask zope.formlib (form.py, line 227)::
# Adapt context, if necessary
interface = field.interface
adapter = interface(context)
Here the answer would be: <InterfaceClass __main__.IBar>
Either way you look at it, one package is wrong and thus broken.
But which is it? It turns out that zope.interface wins and IFoo is returned.
This really hurts zope.formlib. After an initial discussion on IRC, more
people expected IBar, since it is more in line with im_class, but there were
also people expecting IFoo.
Before playing with it, I would like to know what other people think. So, what
do you think?
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training
Zope3-dev mailing list