[Zope3-dev] Allowing views to be registered for classes ratherthan interfaces.

Jim Fulton jim@zope.com
Fri, 18 Jul 2003 13:16:08 -0400


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.

No, it's very explicit. You are saying that you are depending on an
implementation, rather than an interface. You are saying that you
don't care about supportingt alternate implementations and that you
are willing to change your code if the implementation changes.

You are saying you want to be quicj and dirty. Everybody likes to
get dirty once and a while. ;)

(Lately, as I've been thinking about how good Zope 2 is and supporting
"scripters" and realizing that Zope 3 needs needs to be just as supportive of
that audience, I've come to realize that there's a place for quick and
dirty programming. The trick is providing a clean evolution from
dirty to clean.)

> 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.

Nope, not really.

> 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.

I find the nonce interface idea to be far more confusing.
It's a return to the funny Zope 2 magic name rules.  It
treats a class as an interface in a far less honest way.

> How do you use schema with views against classes?

You don't.  When you want to use schema, you have an interface.

> Wouldn't the introspection code become more complicated
> if it is now possible to define views against classes?

Nope. You won't get introspection with classes. When you want to
support additional features, you can switch to using interfaces.

> Steve mentioned some issues with explicit placeholder interfaces which
> don't specify all the methods. I may have misunderstood them, but 
> isn't that a problem with using placeholder interfaces? It'll also
> be harder to distinguish these from real marker interfaces.

Placeholoder interfaces don't help with security assertions.
You'll have to make assertions on attributes directly. Maybe we'll
arrange that trusted (file-system) views registered against classes
won't have to go through security to get at object attributes.

Jim

-- 
Jim Fulton           mailto:jim@zope.com       Python Powered!
CTO                  (703) 361-1714            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org