Hi there,

On 03/20/2011 04:00 PM, Hanno Schlichting wrote:

> Taking one of the examples of grokcore.component, I think there's a
> lot that can be made simpler:
> import grokcore.component
> from zope.i18n.interfaces import ITranslationDomain
> class HelloWorldTranslationDomain(grokcore.component.GlobalUtility):
>      grokcore.component.implements(ITranslationDomain)
>      grokcore.component.name('helloworld')
> Based on my Pyramid exposure, I'd write this as something like:
> from something import utility
> from zope.i18n.interfaces import ITranslationDomain
> @utility(ITranslationDomain, name='helloworld')
> class HelloWorldTranslationDomain(object):
>      pass

It's interesting to consider inheritance rules here. What if you 
subclass from HelloWorldTranslationDomain? What happens to name and the 
interface that the utility is provided under?

I'm not saying I know the right rules for inheritance in all cases, or 
that grokcore.component is sane here, but I know in some cases having 
directive values inherit is pretty neat, and in some cases it isn't. I 
imagine registration can always be explicit, however.

Note also that if we're simply talking spelling, this makes grok a bit 
shorter and is the way Grok code typically looks:

import grokcore.component as grok

from zope.i18n.interfaces import ITranslationDomain

class HelloWorldTranslationDomain(grok.GlobalUtility):



Zope-Dev maillist  -  Zope-Dev@zope.org
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope )

Reply via email to