[Zope3-dev] Allowing views to be registered for classes
ratherthan interfaces.
Phillip J. Eby
pje@telecommunity.com
Fri, 18 Jul 2003 13:00:41 -0400
At 06:49 PM 7/18/03 +0200, Martijn Faassen wrote:
>Jim Fulton wrote:
> > >I don't care what the class-advice function is called.
> >
> > I don't think Garrett was compaining about the name, but about
> > the concept. I too find the concept more complicated that I think
> > is justified by the benefit. Personally, I'd much rather either
> > create an explicit placeholder interface or just register against
> > the class directly.
>
>Okay, asking some questions. Perhaps they're wrong, but I'm just
>throwing them out.
>
>Wouldn't this be too implicit if you can just register against any class
>directly? At least with this proposal you have to *say* something to
>make the class useable that way.
Why should you have to? What if you didn't write the class?
>Wouldn't it be rather complicated to make the interface registries
>and lookup code now also work with classes? Code that just uses
>interfaces sounds easier to optimize too.
You could always "borrow" code from PyProtocols, which uses type-based
registries as a mechanism for both declaring that classes implement
interfaces, *and* as a way of handling adapters between
interfaces. There's C code to speed up the critical path of lookup
operations, and it already supports Zope interfaces today. It even handles
transitive adapters automatically, adapting from Class Z that implements
IFoo to IBar to IBaz, if adapters are defined between IFoo->IBar, and
IBar->IBaz.
>Wouldn't it be conceptually confusing -- won't people wonder what the
>difference is between a class and an interface even more? With this
>proposal people still deal with interfaces and interfaces only.
Which still requires explaining interfaces, and isn't any easier than
explaining why you *have* to have an interface when you don't intend to
make your class replaceable, or need to document it right away, etc. etc.
>How do you use schema with views against classes?
I don't have a clue about Zope 3 schemas, at present, so I'll have to skip
this one.
>Wouldn't the introspection code become more complicated
>if it is now possible to define views against classes?
Introspection code? Huh? Not sure what you're talking about, but in
general I'm against introspection as a means of dispatching. Don't know if
that's related to what you're talking about or not.