Browser views: inherit from object or BrowserView from Five/Plone

Martin Aspeli optilude at gmx.net
Mon Apr 23 23:25:57 UTC 2007


Daniel Nouri wrote:
> Wichert Akkerman wrote:
>> Previously Martin Aspeli wrote:
>>> Maurits van Rees-3 wrote:
>>>> Inherit from Plone
>>>> ------------------
>>>>
>>>>     from Products.CMFPlone import utils
>>>>     class MyView(utils.BrowserView):
>>>>
>>>> Acquisition wrapped, same as Five.
>>>>
>>>> But in the __init__() of this BrowserView there is the line:
>>>>
>>>>     self.context = [context]
>>>>
>>>> So you cannot use self.context in your code like you would do in the
>>>> other cases, but you have to use this:
>>>>
>>>>     context = utils.context(self)
>>>>
>>>> This is the only thing that is different from the Five BrowserView.
>>>> All the browser views in CMFPlone/browser use this.
>>>>
>>> I really hate this view, and we're not using it any more in new views in
>>> Plone 3. This is because:
>>>
>>>  - It makes self.context a list; this breaks compliance with the
>>> IBrowserView interface
>>>  - You have to use that silly utils.context() thing
>>>  - It makes everything have a hard dependency on Products.CMFPlone
>> That view has been annoying me as well. Perhaps we should just get rid
>> of it now.
> 
> +1
> 
> And maybe we should also not recommend it in the Plone Developer's book.
> 

Heh. That bit of text is old, man. :)

Martin





More information about the Product-Developers mailing list