'RESTful method handler, responds to:
- GET [prefix]/[name]/sync.xml          - incoming pull
- PUT|POST [prefix]/[name]/sync.xml     - incoming push
- POST sync/repository/register.json    - remote registration
NB incoming pull/push reponse normally by local sync/sync
controller as resource proxy => back-end generated S3Request
@param r: the S3Request
@param attr: controller parameters for the request'

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

    output = {}
    method = r.method
    if (method == 'sync'):
        if (r.http == 'GET'):
            output = self.__send(r, **attr)
        elif (r.http in ('PUT', 'POST')):
            output = self.__receive(r, **attr)
        else:
            r.error(405, current.ERROR.BAD_METHOD)
    elif (method == 'register'):
        if (r.http in ('PUT', 'POST')):
            if (r.representation == 'json'):
                output = self.__register(r, **attr)
            else:
                r.error(415, current.ERROR.BAD_FORMAT)
        else:
            r.error(405, current.ERROR.BAD_METHOD)
    else:
        r.error(405, current.ERROR.BAD_METHOD)
    return output
