'Represent nodes as labels, the labels are stored in the
nodes as attribute "l".
@param node_ids: the node IDs (None for all nodes)
@param renderer: the representation method (falls back
to the "name" field in the target table
if present)'

def _represent(self, node_ids=None, renderer=None):

    theset = self.theset
    LABEL = 'l'
    if (node_ids is None):
        node_ids = self.nodes.keys()
    pending = set()
    for node_id in node_ids:
        node = theset.get(node_id)
        if (not node):
            continue
        if (LABEL not in node):
            pending.add(node_id)
    if (renderer is None):
        renderer = self.represent
    if (renderer is None):
        tablename = self.tablename
        table = (current.s3db.table(tablename) if tablename else None)
        if (table and ('name' in table.fields)):
            from s3fields import S3Represent
            self.represent = renderer = S3Represent(lookup=tablename, key=self.pkey.name)
        else:
            renderer = s3_unicode
    if hasattr(renderer, 'bulk'):
        labels = renderer.bulk(list(pending), list_type=False)
        for (node_id, label) in labels.items():
            if (node_id in theset):
                theset[node_id][LABEL] = label
    else:
        for node_id in pending:
            try:
                label = renderer(node_id)
            except:
                label = s3_unicode(node_id)
            theset[node_id][LABEL] = label
    return
