'Represent a (key, value) as hypertext link.
@param k: the key (site_id)
@param v: the representation of the key
@param row: the row with this key'

def link(self, k, v, row=None):

    if row:
        try:
            instance_type = row['org_site.instance_type']
            id = row[instance_type].id
        except (AttributeError, KeyError):
            return v
        else:
            (c, f) = instance_type.split('_', 1)
            return A(v, _href=URL(c=c, f=f, args=[id], extension=''))
    else:
        return v
