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

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

    representation = r.representation
    if (representation == 'options'):
        return self._options(r, **attr)
    elif (representation == 'json'):
        if (r.http == 'GET'):
            return self._load(r, **attr)
        elif (r.http == 'POST'):
            if ('delete' in r.get_vars):
                return self._delete(r, **attr)
            else:
                return self._save(r, **attr)
        else:
            r.error(405, current.ERROR.BAD_METHOD)
    elif (representation == 'html'):
        return self._form(r, **attr)
    else:
        r.error(415, current.ERROR.BAD_FORMAT)
