[Grok-dev] Re: A plan for removing the fields inner class support

Philipp von Weitershausen philipp at weitershausen.de
Thu Sep 13 07:57:54 EDT 2007


Luciano Ramalho wrote:
> On 9/13/07, Philipp von Weitershausen <philipp at weitershausen.de> wrote:
>> Dude... Just remove the whole grokker! All it was there for was to set
>> the default values. I don't know why you wanted to keep it around at all.
> 
> Because I saw the other method-less grokkers right after it, I thought
> the component_class attribute was needed for some reason:
> 
> ##############
> class ModelGrokker(martian.ClassGrokker):
>     component_class = grok.Model
> 
>     def grok(self, name, factory, context, module_info, templates):
>         for field in formlib.get_context_schema_fields(factory):
>             setattr(factory, field.__name__, field.default)
>         return True
> 
> 
> class ContainerGrokker(ModelGrokker):
>     component_class = grok.Container
> 
> 
> class LocalUtilityGrokker(ModelGrokker):
>     component_class = grok.LocalUtility
> ##############
> 
> Can anyone explain how this works?

Each of those grokkers picks up differnet kinds of classes but they do 
the same kind of work (in the grok() method).

What I don't understand is why this wasn't written as

   class ModelGrokker(...):
       component_class = (grok.Model, grok.Container, grok.LocalUtility)

in the first place. Oh well, doesn't matter now. Delete'em :)


-- 
http://worldcookery.com -- Professional Zope documentation and training


More information about the Grok-dev mailing list