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

Jim Fulton jim@zope.com
Thu, 17 Jul 2003 09:57:17 -0400


Steve Alexander wrote:
> 
>> Tres has argued (with merit) that only interfaces designed to support 
>> multiple implementations should go in a separate hierarchy.
> 
> 
> I support Tres' argument.
> 
> I think there is value in having a separate place for interfaces that 
> are meant to have a variety of implementations. We might call these 
> "standard interfaces" or somethig like that. We should be careful about 
> changing the contract of a "standard interface" once it has been made 
> available in released software.
> 
> I don't see any harm in putting other interfaces along with their 
> implementations.
> 
> An idea I was kicking around with Martijn Faassen is to have an 
> automatic way of making an interface for a class.
> 
> The idea is that when you are prototyping a class, you don't want to 
> keep an interface in synch with it. Rather, you just want to write and 
> modify the class. However, you still want to be able to hook up views 
> and adapters etc.
> 
> So, we use the common convention that names begining with an underscore 
> are "private" and all other names are part of the interface.
> 
> 
> It might look like this:
> 
>   class Foo:
> 
>       nonceInterface()
> 
>       def bar(self, arg):
>           "Documentation"
>           # do something
> 
>       baz = 23
> 
>       def _spoo(self):
>           # do something private
> 
>       _fish = 99
> 
> The nonceInterface() class advice creates an interface called 
> "Foo.interface" that defines the method bar and the attribute baz. It 
> does not define _spoo or _fish because they start with an underscore. 
> This is a common convention for attributes and operations that do not 
> form part of the public API of an object.

Suppose Foo had a base class.  Would there be a nonceInterface
for the base class? Would there be any relationship between
Foo's nonce interface and the base's nonce interface?

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