Re: Anyone want to do Google Summer of code mentoring for PSF?

Martijn Faassen <[email protected]>
Newsgroups gmane.comp.web.zope.devel
Message-ID <[email protected]>
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):
      grok.implements(ITranslationDomain)
      grok.name('helloworld')

Regards,

Martijn

_______________________________________________
Zope-Dev maillist  -  [email protected]
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.