[Zope-dev] implementing zope.component 4.0
faassen at startifact.com
Sat Nov 28 10:06:24 EST 2009
Charlie Clark wrote:
> Am 27.11.2009, 15:57 Uhr, schrieb Chris Withers <chris at simplistix.co.uk>:
>> Well, I don't think the difference between adapters and utilities is
>> important, but I can understand why some people find calling the
>> interface odd: it is when you think about it objectively.
> I have to agree with this. IFoo(myobject) is not intuitive. I know it used
> a lot because it's convenient shorthand but I've never read anywhere that
> interface classes are, in fact, callables. We certainly don't normally
> treat them as such.
It's quite intuitive to me..
Compare it with plain python:
You say "give me something that's an int for the argument", or "give me
something that's a string for the argument". You don't care how it
accomplishes it, as long as it gives the right value back.
It's even like adapters in the following way:
Gives back the object itself, as it already is an int.
Int is also "registered for" strings and floats, but essential different
styles of "adaptation" happen there.
Calling an interface is really very similar to this.
The main difference is that we don't use the concrete implementation's
factory but that we use the interface that specifies the abstract
behavior. That is a difference, but doesn't seem to be a huge step in my
> One of the things that I have grown to appreciate with the ZCA is the
> advantage of spelling out the relationship between objects and I'll
> happily take a little verbosity over magic.
It's not verbosity versus magic. It's a better API versus a worse API.
> The discussion does highlight a key source of confusion about Zope
> interfaces: they are, at the same time, an object specification and a kind
> of name tag or token that objects can provide upon request. While I know
> that the second function is derived from the first it is conceptually
> My preference, for the sake of clarity:
> adapted = an_easy_way_to_the_registry.adapt(*objects_to_be_adapted,
I'm not sure how this is supposed to work; what is identifiers?
> That adapters are all callable now seems to be an accepted convention,
> presumably from convenience. But my understanding of adapters does not
> imply this.
I hope to have shown to you above that my understanding of adapters does.
More information about the Zope-Dev