[Zope-dev] implementing zope.component 4.0

Gary Poster gary.poster at gmail.com
Mon Nov 30 14:24:40 EST 2009


On Nov 30, 2009, at 1:51 PM, Chris McDonough wrote:

> Shane Hathaway wrote:

...a good general argument, that Chris seemed to agree with and expand upon, and that has some merit to me.

> 
>> What do you think?
> 
> + 1 with the following caveat:
> 
> I think that method name should probably be "adapt"; "lookup"  should maybe be 
> a separate method reserved for passing bare interfaces rather than objects 
> which implement interfaces, e.g:

...

1) I very much like the idea of some helpers hanging around.  However, my current belief is that the factory "methods" ought to be callable objects that allow introspection of the underlying registry.  That's where the "lookup" style behavior belongs, IMO, as well as other helpers.  See below for examples.

2) As argued before, I think that "adapt" is an ok name for a single object, but becomes a bad name once you have "multiadapters" in the mix.  I would prefer one of the options Matthias Lehmann proposed ("new" for instance).

3) I also think that "utility" is a bad name.  Is "singleton" two letters too long?  If it is, I mind "utility" less than I mind "adapter".

IFoo.new(a, b) # finds and returns result of call

IFoo.new.lookup(IA, IB) # finds and returns callable

IFoo.new.find(IA, IB) # get all registration information

IFoo.new.find_stack(IA, IB) # get an iterable of the stack all registration information for each registration for those two interfaces

IFoo.singleton() # finds and returns item

IFoo.singleton(name='baz') # finds and returns item

IFoo.singleton.lookup(name='baz') # same result in this case

IFoo.singleton.find(name='baz') # get all registration information



Side, but related point:

I wonder if there is value in the ability to spell

IFoo.singleton(a) # where "a" is a required object to the registration.  This would make utility registrations more powerful in a way that some people seem to have been missing.  It also makes things parallel with creation.

Gary


More information about the Zope-Dev mailing list