Stephan Richter wrote: > On Thursday 24 August 2006 02:29, Philipp von Weitershausen wrote: >> It's obviously IFoo, because: >> >> >>> IBar['title'] is IFoo['title'] >> True >> >> I sort of expect this. Why? Because it also happens with classes: >> >> >>> class Foo(object): >> ... x = object() >> ... >> >>> class Bar(Foo): >> ... pass >> ... >> >>> Bar.x is Foo.x >> True > > This reasoning is incorrect. You cannot ask x for the class it came from, but > that does not mean you can invert the relationship and make the same > argument.
Good point. > The better equivalent is actually the method, since it stores its > im_class: > > >>> class Foo(object): > ... def foo(self): > ... pass > ... > >>> class Bar(Foo): > ... pass > ... > >>> Bar.foo.im_class > <class '__main__.Bar'> > >>> Bar.foo is Foo.foo > False > >> Now, you could say that interfaces don't necessarily have follow class >> semantics just because they're defined via the class statement.... > > I never said it has to follow those semantics. I merely noted that several > very experienced developers gave the opposite answer (myself included) and > the incorrect behavior in formlib is another proof of that. Thus I am > questioning the current behavior and think that we should change it. formlib's use of the 'interface' attribute indeed suggests that people would expect a different behaviour. Feeling pretty much indifferent about this, I just wonder if there are any potential repercussions. For example, changing the behaviour will mean that extending an interface will cause all fields (incl. attr and method definitions) to be copied in the new interface. Any modifications on the base interface fields will not be seen in the subinterface... > I do think that not being able to deduce the interface of a field correctly > is > a serious drawback. Yup. In fact, I wonder if Attribute.interface is actually used for something valuable. I'm pretty sure formlib's form fields don't really need it, they already get the schema passed. Plus, a schema field is pretty useless w/o the original schema information anyways (because we expect formlib to adapt to the schema), therefore I wouldn't mind always having to specify the interface that a schema field comes from. We already can do this anyhoo: form_fields = FieldFromInterface(IFoo) form_fields = FieldFromInterface(IFoo).select('foo') form_fields = FieldFromInterface(IFoo).omit('bar') etc. Philipp _______________________________________________ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com