<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def process_request(self, req):
 """ Process the given request `req`, implements an `IRequestHandler` API. Normally, `process_request` would return a tuple, but since none of these requests will return an HTML page, they will all terminate without a return value and directly send a response. """

        if os.environ.get('TRAC_GITHUB_ENABLE_DEBUGGING', None) is not None:
            debug_match = self._debug_request_re.match(req.path_info)
            if debug_match:
                self.process_debug_request(req)

        if req.method != 'POST':
            msg = u'Endpoint is ready to accept GitHub Organization membership notifications.\n'
            self.log.warning(u'Method not allowed (%s)', req.method) # pylint: disable=no-member
            req.send(msg.encode('utf-8'), 'text/plain', 405)

        event = req.get_header('X-GitHub-Event')
        supported_events = {
            'ping': self._handle_ping_ev,
            'membership': self._handle_membership_ev
        }

        # Check whether this event is supported
        if event not in supported_events:
            msg = u'Event type %s is not supported\n' % event
            self.log.warning(msg.rstrip('\n')) # pylint: disable=no-member
            req.send(msg.encode('utf-8'), 'text/plain', 400)

        # Verify the event's signature
        reqdata = req.read()
        signature = req.get_header('X-Hub-Signature')
        if not self._verify_webhook_signature(signature, reqdata):
            msg = u'Webhook signature verification failed\n'
            self.log.warning(msg.rstrip('\n')) # pylint: disable=no-member
            req.send(msg.encode('utf-8'), 'text/plain', 403)

        # Decode JSON and handle errors
        try:
            payload = json.loads(reqdata)
        except (ValueError, KeyError):
            msg = u'Invalid payload\n'
            self.log.warning(msg.rstrip('\n')) # pylint: disable=no-member
            req.send(msg.encode('utf-8'), 'text/plain', 400)

        # Handle the event
        try:
            supported_events[event](req, payload)
        except RequestDone:
            # Normal termination, bubble up
            raise
        except Exception: # pylint: disable=broad-except
            msg = (u'Exception occurred while handling payload, '
                   'possible invalid payload\n%s' % traceback.format_exc())
            self.log.warning(msg.rstrip('\n')) # pylint: disable=no-member
            req.send(msg.encode('utf-8'), 'text/plain', 500)