[Grok-dev] fixing viewlet url() method ( https://bugs.launchpad.net/grok/+bug/226555 )

Jan-Wijbrand Kolman janwijbrand at gmail.com
Mon Jun 16 15:47:14 EDT 2008


Hi,

Let me try to summarize the changes on:

   http://svn.zope.org/grok/branches/jw-viewlets-fix/

which are supposed to be a fix for:

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


* Both Viewlet and ViewletManager instances have a reference to the View 
they're registered for by `self.view`. Likewise, a Viewlet will have a 
reference to the ViewletManager it is registered for by `self.manager`.

* As a result of having a reference to a View instance in the 
Viewlet(Manager), there's no need anymore for having an 
(application_)url() method on the Viewlet(Manager). This prevents 
duplication of code and makes migrating view code into viewlet easy. It 
also makes explaining what this url() method will return very easy.

These were the easy fixes.

The second part of the fix is to have the view, viewlet and manager 
namespaces available in the associated (page)templates (for one, to have 
the view reference available for computing URLs).

Grok currently determines what namespace to "push" into the template by 
default in the GrokTemplate baseclass. There's no way for view(-like) 
components to determine the *default* set of namespace themselves.

On the jw-viewlets-fix branch I introduce default_namespace() on 
view(-like) components method that is called by the GrokTemplate 
baseclass. That way the Viewlet and ViewletManager baseclasses can 
"push" in the extra namespaces 'viewlet' and 'manager' for the template 
to use. I added this default_namespace() method to IGrokView interface.

Al in all, the changes are not very complicated, but they to move the 
responsibility for determining the namespaces from the template classes 
to the view components.

Question:

What do people think of this?

If people agree on this change I can merge the changes.


kind regards,
jw





More information about the Grok-dev mailing list