'Execute this request
@param attr: Parameters for the method handler'

def __call__(self, **attr):

    response = current.response
    s3 = response.s3
    self.next = None
    bypass = False
    output = None
    preprocess = None
    postprocess = None
    representation = self.representation
    if ((not self.id) and (representation == 'html')):
        if (self.component or (self.method in ('read', 'profile', 'update'))):
            count = self.resource.count()
            if ((self.vars is not None) and (count == 1)):
                self.resource.load()
                self.record = self.resource._rows[0]
                self.id = self.record.id
            else:
                redirect(URL(r=self, c=self.prefix, f=self.name))
    if (s3 is not None):
        preprocess = s3.get('prep')
    if preprocess:
        pre = preprocess(self)
        representation = self.representation
        if (pre and isinstance(pre, dict)):
            bypass = (pre.get('bypass', False) is True)
            output = pre.get('output')
            if (not bypass):
                success = pre.get('success', True)
                if (not success):
                    if ((representation == 'html') and output):
                        if isinstance(output, dict):
                            output['r'] = self
                        return output
                    else:
                        status = pre.get('status', 400)
                        message = pre.get('message', current.ERROR.BAD_REQUEST)
                        self.error(status, message)
        elif (not pre):
            self.error(400, current.ERROR.BAD_REQUEST)
    if (representation not in ('html', 'popup')):
        response.view = 'xml.html'
    response.headers['Content-Type'] = s3.content_type.get(representation, 'text/html')
    if (not self.custom_action):
        action = current.s3db.get_method(self.prefix, self.name, component_name=self.component_name, method=self.method)
        if isinstance(action, (type, types.ClassType)):
            self.custom_action = action()
        else:
            self.custom_action = action
    http = self.http
    handler = None
    if (not bypass):
        if (self.method and self.custom_action):
            handler = self.custom_action
        elif (http == 'GET'):
            handler = self.__GET()
        elif (http == 'PUT'):
            handler = self.__PUT()
        elif (http == 'POST'):
            handler = self.__POST()
        elif (http == 'DELETE'):
            handler = self.__DELETE()
        else:
            self.error(405, current.ERROR.BAD_METHOD)
        if (handler is not None):
            output = handler(self, **attr)
        else:
            output = self.resource.crud(self, **attr)
    if (s3 is not None):
        postprocess = s3.get('postp')
    if (postprocess is not None):
        output = postprocess(self, output)
    if ((output is not None) and isinstance(output, dict)):
        output['r'] = self
    if ((self.next is not None) and ((self.http != 'GET') or (self.method == 'clear'))):
        if isinstance(output, dict):
            form = output.get('form')
            if form:
                if (not hasattr(form, 'errors')):
                    form = form.elements('form', first_only=True)
                    form = (form[0] if form else None)
                if (form and form.errors):
                    return output
        session = current.session
        session.flash = response.flash
        session.confirmation = response.confirmation
        session.error = response.error
        session.warning = response.warning
        redirect(self.next)
    return output
