Skip to content

The linkify kwarg doesn't support adding a querystring the way LinkColumn's render_link method did. #687

@benmehlman

Description

@benmehlman

Prior to the addition of linkify it was possible to customize the behavior of LinkColumn by overriding the render_link method. I did this, implementing a LinkTemplateColumn which supported the passing of a querystring template to be rendered and appended to the url.

I am now upgrading tables2 and see that LinkColumn has been changed to a wrapper and the url rendering has been moved to LinkTransform where it can't be overridden.

Three possible ways to get around this:

  1. Add querystring rendering capabilities to the LinkTransform class through an extra entry in the linkify dict (ideally this would support templating).

  2. Make the LinkTransform class swappable by adding a layer of indirection, eg.

     class Column():
         link_transform = LinkTransform
     
     MyLinkTransform(LinkTransform):
         pass
    
     Column.link_transform = MyLinkTransform
    

    (or we could get fancier than that...)

  3. Make Column.link into a method that could be overridden, eg.

    def link_transform(self, **kwargs)
        return  LinkTransform(attrs=self.attrs.get("a", {}), **lkwargs)
    

The alternatives (for me) that do not involve changes to tables2:

  1. I could subclass the existing LinkTransform class, and implement querystring functionality.. then override its callable so that it would return a bare url with my querystring appended. Then pass an instance of this as the value of linkify. At least that way I take advantage of the existing linkify code and keep current with any changes to it.

  2. Or I could simply make my own callable that renders the url, bypassing tables2's url capabilities, and pass that as the value of linkify.. but that's no fun, is it???

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions