-
Notifications
You must be signed in to change notification settings - Fork 437
Description
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:
-
Add querystring rendering capabilities to the LinkTransform class through an extra entry in the linkify dict (ideally this would support templating).
-
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...)
-
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:
-
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.
-
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?