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

Jan-Wijbrand Kolman janwijbrand at gmail.com
Mon Jun 4 09:26:35 EDT 2007


Reviving an older discussion:

> I suggest using several decorators:
>
>    class Mammoth(grok.Model):
>        pass
>
>    @grok.adapter(Mammoth)  # (works like z.c.adapter)
>    @grok.implementer(IFoo) # (works like z.i.implementer)
>    def fooForMammoths(mammoth):
>        pass
>
> I don't think @grok.provider isn't needed. I see no use case for
> specifying more than one interface in @grok.implementer and then
> selecting only one of them for the adapter registration. This is useful
> for a class, but not for a function.
>
> Note that grok.adapter would be a slight variant of z.c.adapter that
> would support grok's DRY rules. Therefore, you could also leave out the
> adapted object if it's the current model:
>
>    class Mammoth(grok.Model):
>        pass
>
>    @grok.adapter
>    @grok.implementer(IFoo)
>    def fooForMammoths(mammoth):
>        pass
>
> What do you think?

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?

kind regards,
jw
-- 
Jan-Wijbrand Kolman


More information about the Grok-dev mailing list