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

Garrett Smith garrett@mojave-corp.com
Fri, 18 Jul 2003 12:33:30 -0500


Jim Fulton wrote:
> ratherthaninterfaces.
>=20
>=20
> Martijn Faassen wrote:
>> Jim Fulton wrote:
>>=20
>>>> I don't care what the class-advice function is called.
>>>=20
>>> 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.
>>=20
>>=20
>> Okay, asking some questions. Perhaps they're wrong, but I'm just
>> throwing them out.=20
>>=20
>> 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.
>=20
> 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.
>=20
> You are saying you want to be quicj and dirty. Everybody likes to
> get dirty once and a while. ;)
>=20
> (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.)
>=20
>> 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.
>=20
> Nope, not really.
>=20
>> 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.
>=20
> 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.

Developers have to go through ZCML to define class permissions. What
about an option, in the content or class directives, to define an
implicit interface -- like a macro. I'm not sure what this would look
like...an 'interface' or 'schema' or multiple 'method/attribute'
subdirectives.

This could serve the primary purpose, if I understand Jim's main
concern, for explicit contract definition. It would also ensure that an
interface and class were always in sync, eliminating the tedium that
Martijn mentioned in an earlier message.

This is also a common Zope 3 pattern -- supporting certain
definition/registration tasks in ZCML that would otherwise be required
in Python.

 -- Garrett