url() on viewlets is not updated in trunk

Bug #226555 reported by Martijn Faassen on 2008-05-04
4
Affects Status Importance Assigned to Milestone
grok
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.

Martijn Faassen (faassen) wrote :

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

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.

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

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

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....

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  Edit
Everyone can see this information.

Other bug subscribers