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

Leonardo Rochael Almeida leorochael at gmail.com
Thu May 8 13:33:49 EDT 2008


On Thu, May 8, 2008 at 2:22 PM, Martijn Faassen <faassen at startifact.com> wrote:
> Hey Kevin,
>
> Thanks for your feedback!
>
> Kevin Smith wrote:
> [snip]
>>
>> Thinking out loud, it may be possible in a viewlet to map the 'view'
>>  namespace directly to the parent view and then supply a 'viewlet'
>> namespace that maps directly to the viewlet.
>
> This sounds attractive. It of course makes sense to have 'view'
> still map to a view, and a viewlet will always
> have a view available. It will work for the refactoring a view into viewlets
> use case, and it makes it clear whether you're accessing methods on a view
> or a viewlet.
>
> +1 for exploring this: a 'view' namespace in the template which points to a
> real view, and a 'viewlet' namespace in the template that points to the
> viewlet. I think in this case it would make sense to establish a 'view'
> attribute in the viewlet class as well.

+1 from me as well. I was about to reply with a quip from "The Zen of Python":

 * In the face of ambiguity, refuse the temptation to guess.

Viewlets currently don't have a URL, so their .url() method, if
present, should necessarily require a parameter, I'd actually prefer
it not be present at all, but then, as reported, calculating urls in a
template would get cumbersome. Truth is that the word "view", inside a
viewlet (which is necessarily bound to a viewlet manager, which is
bound to a view), already introduces a lot of ambiguities just for
refering to the viewlet instead of the view.

So I strongly second the idea of 'view' referring to the bound view,
and an eventual 'viewlet' to refert to the viewlet itself. And perhaps
we should throw "manager" there for good measure, as an alias to
__parent__.

> [...]

Cheers, Leo


More information about the Grok-dev mailing list