def emit(self, record):
        if record.levelno <= logging.ERROR and self.can_record(record):
            request = None
            exc_info = None
            for frame_info in getouterframes(currentframe()):
                frame = frame_info[0]
                if not request:
                    request = frame.f_locals.get('request', None)
                    if not request:
                        view = frame.f_locals.get('self', None)
                        try:
                            request = getattr(view, 'request', None)
                        except RuntimeError:
                            request = None
                if not exc_info:
                    exc_info = frame.f_locals.get('exc_info', None)
                    if not hasattr(exc_info, '__getitem__'):
                        exc_info = None
                if request and exc_info:
                    break

            if exc_info:
                record.exc_info = exc_info
                record.stack = \
                    iter_stack_frames(getinnerframes(exc_info[2]))
            if request:
                try:
                    body_pos = request.stdin.tell()
                    request.stdin.seek(0)
                    body = request.stdin.read()
                    request.stdin.seek(body_pos)
                    http = dict(headers=request.environ,
                                url=request.getURL(),
                                method=request.method,
                                host=request.environ.get('REMOTE_ADDR',
                                ''), data=body)
                    if 'HTTP_USER_AGENT' in http['headers']:
                        if 'User-Agent' not in http['headers']:
                            http['headers']['User-Agent'] = \
                                http['headers']['HTTP_USER_AGENT']
                    if 'QUERY_STRING' in http['headers']:
                        http['query_string'] = http['headers']['QUERY_STRING']
                    setattr(record, 'request', http)
                    user = request.get('AUTHENTICATED_USER', None)
                    if user is not None and user != nobody:
                        user_dict = {
                            'id': user.getId(),
                            'email': user.getProperty('email') or '',
                        }
                    else:
                        user_dict = {}
                    setattr(record, 'user', user_dict)
                except (AttributeError, __HOLE__):
                    logger.warning('Could not extract data from request', exc_info=True)
        return super(ZopeSentryHandler, self).emit(record)
dataset/ETHPy150Open getsentry/raven-python/raven/contrib/zope/__init__.py/ZopeSentryHandler.emit