'Entry point for REST interface
@param r: the S3Request
@param attr: controller attributes'

def apply_method(self, r, **attr):

    if (r.http == 'GET'):
        if (r.representation == 'html'):
            output = self.tree(r, **attr)
        elif ((r.representation == 'json') and ('node' in r.get_vars)):
            output = self.node_json(r, **attr)
        elif (r.representation == 'xls'):
            output = self.export_xls(r, **attr)
        else:
            r.error(415, current.ERROR.BAD_FORMAT)
    else:
        r.error(405, current.ERROR.BAD_METHOD)
    return output
