[PEAK] The road to PyProtocols 1.0

Phillip J. Eby pje at telecommunity.com
Sun May 30 13:40:24 EDT 2004


At 08:39 AM 5/30/04 +0200, Gabriel Jägenstedt wrote:
>On Sun, 30 May 2004 01:43:15 -0400
>"Phillip J. Eby" <pje at telecommunity.com> wrote:
>
> > * If 'factory' isn't used anywhere, consider ditching the second
> > parameter passed to adapters.  That is, instead of calling
> > 'someadapter(ob,proto)', just call 'someadapter(ob)'.  This would give
> > PyProtocols adapters the same calling signature as e.g. Zope adapters.
>
>I don't quite understand what this would imply...
>currently I call adapt with three parameters adapt(ob,proto, default)
>what does it mean to remove proto?
>Or am I missunderstanding where you're coming from?

I'm not talking about changing 'adapt()', but rather the functions one uses 
as adapters.  For example, if you have a protocol IInteger, and define an 
adapter function thus:

     def makeInteger(ob,proto):
         return int(ob)

     declareAdapter(makeInteger,provides=[IInteger],forTypes=[object])


I am proposing this be changed to:


     def makeInteger(ob):
         return int(ob)

     declareAdapter(makeInteger,provides=[IInteger],forTypes=[object])

Thus removing the unused 'proto' argument.  Jim Fulton has previously 
pointed out that none of PEAK's adapter functions or classes ever use the 
'proto' argument, and that for any given case where you might need it, it 
can be supplied by the declarer anyway (though perhaps awkwardly).  So I'm 
considering dropping it.




More information about the PEAK mailing list