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

Tim Terlegård tim.terlegard at valentinewebsystems.se
Thu May 8 09:28:09 EDT 2008


On May 8, 2008, at 9:52 AM, Jan-Wijbrand Kolman wrote:

> The current url() methods on viewlets and viewletmanagers are  
> broken. They apparently returns incorrect URLs, the code is  
> duplicated all over the place, and on the trunk these methods have  
> not been updated according the updates the view.url() got during the  
> Grokkerdam sprint and there're no tests.
>
> I assigned myself to the issue and I've been working on a fix for a  
> bit, but I need your help.
>
> Let me try to summarize my thinking:
>
> The url() methods for viewletmanagers and viewlets should return  
> basically *identical* URLs to what the url() method on a regular  
> view for the same object would return.
>
> * Question: is this interpretation of the issue correct?

I would expect a viewlet url method to return a url that would allow you
to see that viewlet in the browser. I don't think a viewlet url method  
should
just be an alias to it's view (__parent__) url method. That would be  
confusing.


> * Related question: during the sprint someone expressed the desire  
> for a way to construct URLs to individual viewlets. How does that  
> relate to this issue? Or should we ignore this for now?

I think we can ignore that, atleast for now. The use case I can think  
of would be
for caching. This can be accomplished by using z3c.traverser.viewlet and
lovely.remoteinclude. The url() method would not help in that case  
because
those packages are not using a url method, they use the IAbsoluteURL  
adapter
and it's available for viewlets if you use z3c.traverser.viewlet.


> There's no Grok-specific interface for viewlet(manager)s. We might  
> want one, since we're adding the url() method. And if we decide we  
> want the 'view' attribute as well, this can then be added to this  
> specialized interface. However, I think this could create confusion,  
> whenever a viewlet(manager) that is not created through Grok is  
> being used since this viewlet probably does not have the view  
> attribute nor the url() method.
>
> * Question: is it then actually a good thing that Grok extends the  
> viewlet (and contentprovider) interfaces? Or in other words, isn't  
> the bug really that there *is* a url method and should it thus be  
> removed?

The url() method on viewlets and viewlet managers are probably a left- 
over
from the old viewlet branch which we based our work on. I'm not sure  
about
the use cases for the url method. Is anyone using it?

I vote for removing it if there's no good use case for it.

/Tim


More information about the Grok-dev mailing list