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

Philipp von Weitershausen philipp at weitershausen.de
Fri May 9 20:39:24 EDT 2008


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?



More information about the Grok-dev mailing list