callable url in LinkAction TemplateSyntaxError

Bug #1290909 reported by Matthew D. Wood
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Dashboard (Horizon)
Fix Released
Low
John Davidge

Bug Description

According to the doc-string for horizon.tables.actions.LinkAction.get_link_url:

 If ``url`` is callable it will call the function.

Here's the snippit that does the call:

        if callable(self.url):
            return self.url(datum, **self.kwargs)

However, self.kwargs is not set anywhere (should probably be set in __init__).

This will result in an AttributeError or TemplateSyntaxError.

In searching through the code-base, I don't see a single use of a callable url, so perhaps this is dead code? The dead-code-hypothesis is supported by the classes doc-string which hints that overriding get_link_url is the correct strategy:

    .. attribute:: url

        A string or a callable which resolves to a url to be used as the link
        target. You must either define the ``url`` attribute or override
        the ``get_link_url`` method on the class.

Akihiro Motoki (amotoki)
tags: added: horizon-core
Changed in horizon:
importance: Undecided → Low
status: New → Confirmed
tags: added: low-hanging-fruit
Changed in horizon:
assignee: nobody → John Davidge (john-davidge)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to horizon (master)

Fix proposed to branch: master
Review: https://review.openstack.org/115286

Changed in horizon:
status: Confirmed → In Progress
David Lyle (david-lyle)
Changed in horizon:
milestone: none → juno-3
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to horizon (master)

Reviewed: https://review.openstack.org/115286
Committed: https://git.openstack.org/cgit/openstack/horizon/commit/?id=5d6bc4e914da30714acf27007869ce604bf9247d
Submitter: Jenkins
Branch: master

commit 5d6bc4e914da30714acf27007869ce604bf9247d
Author: johndavidge <email address hidden>
Date: Tue Aug 19 06:23:37 2014 -0700

    Set self.kwargs in horizon.tables.actions.LinkAction

    Set self.kwargs during __init__ so that get_link_url no longer raises
    an AttributeError at "return self.url(datum, **self.kwargs)".

    Change-Id: I97aeab781ee1945c3028590be0a6a046c7fcd9b9
    Closes-Bug: 1290909

Changed in horizon:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in horizon:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in horizon:
milestone: juno-3 → 2014.2
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.