[PEAK] And so it begins... (generic function migration)
Phillip J. Eby
pje at telecommunity.com
Tue Nov 16 17:30:17 EST 2004
Just a quick status report on the generic function conversions within PEAK:
At 12:07 AM 11/11/04 -0500, Phillip J. Eby wrote:
>Here are some current candidates for potentially switching from interfaces
>to single-dispatch generic functions:
>* binding.IComponentKey -- findComponent()
I've decided to leave this one alone; the normal use of this is such that
the adapters are not obtained on-the-fly. Instead, they typically sit
inside 'binding.Obtain' instances for later use, so there's little runtime
overhead for adapter creation.
>* binding.IAttachable -- setParentComponent()
>* binding.IBindingNode -- getParentComponent(), getComponentName()
These are both implemented in CVS. IAttachable remains an interface, but
IBindingNode was consolidated into IComponent. If you want to implement
parts of the old IBindingNode, you should just add cases to
'binding.getParentComponent' or 'binding.getComponentName'.
(Note that this change may break code that relies on using
'someOb.getParentComponent()' or 'someOb.getComponentName()' if 'someOb' is
not a binding.Component. You should've been using 'binding.getXXX(ob)' all
along, not 'ob.getXXX()'.)
>* config.IStreamSource -- getFactory()
Done; replaced with 'config.getStreamFactory()' in CVS.
>* naming.IBaseURL -- joinURL()
This one won't be changed; mostly it is implemented directly in URL classes
that it's useful for, so there's no real benefit to switching.
>* naming.IReferenceable -- getReference()
For this one, I dropped the interface entirely, since it's not currently
used. When the functionality it envisions is actually implemented,
however, we'll use a GF.
>* net.IClientSockAddr -- connect_addrs()
>* net.IListenSockAddr -- listen_addrs()
These won't be changed right now, but whenever I get back to working on
'peak.net' stuff, this will be revisited.
>* running.ICheckableResource -- checkResource()
No immediate benefit, but whenever I get back to working on
peak.running.daemons and friends, this one will also be revisited.
>* security.IAuthorizedPrincipal -- checkGlobalPermission()
>* security.IPermissionChecker -- checkPermission()
>* security.IGuardedObject -- getPermissionForName() [full GF?]
These are still pending, waiting to get done as part of a complete
refactoring of peak.security, using generic functions (and predicate
dispatch) throughout. The rewrite will also make use of the coming
"attribute metadata" framework.
>* web.IViewTarget -- registerWithProtocol()
Done and in CVS. This one could maybe become an API function of
PyProtocols itself, but for now it's just a private generic function used
to implement the Location facility.
>* Virtually all peak.model interfaces [full GF's]
This is actually going to get tackled in the peak.schema rewrite.
>* running.IExecutable and friends
I've completed the review of this one, and decided to do only slight tweaks
to the current setup. (See my previous post at:
for more info.)
More information about the PEAK