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

Jan-Wijbrand Kolman janwijbrand at gmail.com
Thu May 8 03:52:42 EDT 2008

See https://bugs.launchpad.net/grok/+bug/226555


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?

* 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?

In order to re-implement the url() methods on viewlet(manager), the 
viewlet(manager) instance needs a reference to the view it was adapted 
to (together with the context object and request). Looking at the 
viewlet(manager) interfaces in zope.viewlet and zope.contentprovider, 
this relationship is expressed through the __parent__ attribute on the 

* Question: allthough I see the necessity for calling this attribute 
'__parent__', I can imagine having it assigned to an attribute called 
'view' as well would make it slightly more obvious how to use it for the 
developer using viewlets. Would that be an idea?

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?

kind regards,

More information about the Grok-dev mailing list