[Grok-dev] Re: issue #226555: viewlet.url() and how to solve it

kevin at mcweekly.com kevin at mcweekly.com
Fri May 9 23:30:58 EDT 2008


Quoting Philipp von Weitershausen <philipp at weitershausen.de>:

> Kevin Smith wrote:
>> Leonardo Rochael Almeida wrote:
>>> On Thu, May 8, 2008 at 4:39 PM, Jan-Wijbrand Kolman
>>> <janwijbrand at gmail.com> wrote:
>>>
>>>> Leonardo Rochael Almeida wrote:
>>>>
>>>>> On Thu, May 8, 2008 at 3:48 PM, Kevin Smith <kevin at mcweekly.com> wrote:
>>>>>
>>>>>> [...]
>>>>>> class ViewletBase(BrowserView):
>>>>>> """Viewlet adapter class used in meta directive as a mixin class."""
>>>>>>
>>>>>> zope.interface.implements(interfaces.IViewlet)
>>>>>>
>>>>>> def __init__(self, context, request, view, manager):
>>>>>>     super(ViewletBase, self).__init__(context, request)
>>>>>>     self.__parent__ = view
>>>>>>     self.context = context
>>>>>>     self.request = request
>>>>>>     self.manager = manager
>>>>>>
>>>>>> Looks like __parent__ is the view, and manager is the viewletmanager....
>>>>>> I'm not sure the viewlet is actually accessible here at all.
>>>>>>
>>>>> The viewlet is accessible as "self" :-) the view is
>>>>> self.__parent__.__parent__, right?
>>>>>
>>>> I would say, self.__parent__ is the view the viewlet was registered for.
>>>>
>>>
>>> Ah, yes, of course
>>>
>> Looks like a viewlet wart. You and I expect the __parent__ of a   
>> viewlet to be it's viewletmanager .
>
> I don't really see why. The viewlet manager is really just a dispatcher
> for adapter lookup. It has no actual meaning regarding data or security
> so why it should it be part of the object hierarchy?

Good question.

It feels inconsistent to me. It feels like a viewlet is the child of a  
viewletmanager, and so I expect the viewletmanager to be the parent,  
even though a viewletmanager may technically *function* as a dispatcher.

I have to *remember* that __parent__ is the view class.

It may be because viewletmanager may mean something a little different  
to me than to someone else. I'm not proposing this but if it were  
called a viewletdispatcher, I would more readily concede.

Are there other places in Grok that exhibit similar  
__parent__/dispatch behavior?


Kevin Smith



More information about the Grok-dev mailing list