[Grok-dev] Re: Does it make sense: registering factories that are functions not classes

Darryl Cousins darryl at darrylcousins.net.nz
Tue Jun 5 08:47:06 EDT 2007


Hi,

On Tue, 2007-06-05 at 11:06 +0200, Jan-Wijbrand Kolman wrote:
> > I would very much like to have this. I'd like to give it a shot and
> > try to implement it. Just to be sure: noone got arround working on
> > this so far, right?
> 
> http://svn.zope.org/grok/branches/jw-adapter-decorator now contains
> this feature.
> 
> I would very much appreciate it if someone would review the code for
> this feature and when needed provide me with feedback. After the code
> reviewd, I can merge it with the trunk.

I checked out the branch and tried the decorators. It seems then you can
only use a method for the adaptor. Is this expected or is there a way to
use classes that I'm missing? For example to get ISized I needed to use
the method to return a class:

@grok.adapter(JanW)
@grok.implementer(ISized)
def sizedForJanW(context):
	return ActualSizedAdapterForJanW(context)

Which gets me an adapter class *and* a decorated method. Surely just as
easy to use an adapter sub-classing grok.Adapter. From memory all my
adapters to date need to be classes.

I'm sure I'm missing something and am keen to be enlightened.

Best regards,
Darryl

> 
> 
> kind regards,
> jw
> 



More information about the Grok-dev mailing list