url() on viewlets is not updated in trunk

Bug #226555 reported by Martijn Faassen
4
Affects Status Importance Assigned to Milestone
grok
Fix Released
Medium
Jan Wijbrand Kolman

Bug Description

The url() method implementation is duplicated on viewlet and views. This duplication should go away. Right now as a result of this duplication there's also an inconsistency between url on views (which get a data argument) and on viewlet. There are also no tests for the url method on viewlet.

Revision history for this message
Martijn Faassen (faassen) wrote :

The viewletmanager also has a copy which needs to be consolidated.

Revision history for this message
Reed O'Brien (reedobrien) wrote :

given a viewlet manager:

class HeaderManager(grok.ViewletManager):
    grok.name('header')
    grok.context(site)

and a viewlet:

class HeaderViewlet(grok.Viewlet):
    grok.viewletmanager(HeaderManager)
    grok.context(site)
    grok.template('header')

The view.url method in the header ZPT:

<div id="visual-wrapper">
  <div id="site-header">
   <p class="hidden-structure">
     <a tal:attributes="href python:view.url() + u'/#content';
   accesskey string:2;
   title string:Skip to content">Skip To Content</a>
...

generates the url:

http://url/app/index/headerviewlet/#content

which doesn't exist, so giving context is required to generate a working url.

<a tal:attributes="href python:view.url(context) + u'/#content';

generates:

http://url:8080/app/#content

Which is correct.

I do not know if this is intended behavior, but per a conversation with philiKON in #grok
(http://jw.n--tree.net/irclogs/%23grok/%23grok.2008-05-04.log.html) I am filing this.

Revision history for this message
Philipp von Weitershausen (philikon) wrote : Re: [Bug 226555] Re: url() on viewlets is not updated in trunk

On 4 May 2008, at 23:16 , Reed O'Brien wrote:
> given a viewlet manager:
>
> class HeaderManager(grok.ViewletManager):
> grok.name('header')
> grok.context(site)
>
> and a viewlet:
>
> class HeaderViewlet(grok.Viewlet):
> grok.viewletmanager(HeaderManager)
> grok.context(site)
> grok.template('header')
>
> The view.url method in the header ZPT:
>
> <div id="visual-wrapper">
> <div id="site-header">
> <p class="hidden-structure">
> <a tal:attributes="href python:view.url() + u'/#content';
> accesskey string:2;
> title string:Skip to content">Skip To Content</a>
> ...
>
> generates the url:
>
> http://url/app/index/headerviewlet/#content

This URL (generated by a viewlet's url() method) is definitely
incorrect. Thanks for providing this bugreport!

Changed in grok:
assignee: nobody → janwijbrand
importance: Undecided → Medium
milestone: none → 1.0
status: New → In Progress
Revision history for this message
Martijn Faassen (faassen) wrote :

On Thu, May 8, 2008 at 9:15 AM, Jan Wijbrand Kolman
<email address hidden> wrote:
> ** Changed in: grok
> Status: New => In Progress
> Target: None => 1.0

I'd make this a 0.13 target, not a 1.0 target?

Revision history for this message
Martijn Faassen (faassen) wrote :

On Thu, May 8, 2008 at 1:12 PM, Martijn Faassen <email address hidden> wrote:
> On Thu, May 8, 2008 at 9:15 AM, Jan Wijbrand Kolman
> <email address hidden> wrote:
>> ** Changed in: grok
>> Status: New => In Progress
>> Target: None => 1.0
>
> I'd make this a 0.13 target, not a 1.0 target?

Or even a 0.12.1 target actually

Revision history for this message
Jan Wijbrand Kolman (janwijbrand) wrote :

Yes, it is really a 0.12.1 and 0.13 target. Now, if only I could find out how to actually set it on the issue....

Revision history for this message
Jan Wijbrand Kolman (janwijbrand) wrote :

After discussions on the mailinglist, the consensus appears to be:

* viewlets and viewletmanagers should provide access to the view they're registered for, besides the request and the context.

* the namespaces for the pagetemplates associated with a viewlet or a viewletmanager should be at least: request, viewletmanager, viewlet (the viewlet object itself), view (the view the viewlet[manager] is registered for) and context.

* URLs to views can thus be constructed through the view namespace (being the view this viewlet is regsitered for) as it has the url() method. In other words, the url() method will be removed from viewlet and viewletmanager.

* at some point in the future the suggestions for having URLs to the individual viewlets can be explorered.

* Test coverage for the viewlets should be extended.

Changed in grok:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.