rollbar/__init__.py
def _build_person_data(request):
    """
    Returns a dictionary describing the logged-in user using data from `request.

    Try request.rollbar_person first, then 'user', then 'user_id'
    """
    if hasattr(request, 'rollbar_person'):
        rollbar_person_prop = request.rollbar_person
        try:
            person = rollbar_person_prop()
        except TypeError:
            person = rollbar_person_prop

        if person and isinstance(person, dict):
            return person
        else:
            return None

    if hasattr(request, 'user'):
        user_prop = request.user
        try:
            user = user_prop()
        except TypeError:
            user = user_prop

        if not user:
            return None
        elif isinstance(user, dict):
            return user
        else:
            retval = {}
            if getattr(user, 'id', None):
                retval['id'] = text(user.id)
            elif getattr(user, 'user_id', None):
                retval['id'] = text(user.user_id)

            # id is required, so only include username/email if we have an id
            if retval.get('id'):
                username = getattr(user, 'username', None)
                email = getattr(user, 'email', None)
                retval.update({
                    'username': username,
                    'email': email
                })
            return retval

    if hasattr(request, 'user_id'):
        user_id_prop = request.user_id
        try:
            user_id = user_id_prop()
        except TypeError:
            user_id = user_id_prop

        if not user_id:
            return None
        return {'id': text(user_id)}
def _build_person_data(request):
    if hasattr(request, 'rollbar_person'):
        rollbar_person_prop = request.rollbar_person
        try:
            person = rollbar_person_prop()
        except TypeError:
            person = rollbar_person_prop

        if person and isinstance(person, dict):
            return person
        else:
            return None

    if hasattr(request, 'user'):
        user_prop = request.user
        try:
            user = user_prop()
        except TypeError:
            user = user_prop

        if not user:
            return None
        elif isinstance(user, dict):
            return user
        else:
            retval = {}
            if getattr(user, 'id', None):
                retval['id'] = text(user.id)
            elif getattr(user, 'user_id', None):
                retval['id'] = text(user.user_id)

            # id is required, so only include username/email if we have an id
            if retval.get('id'):
                username = getattr(user, 'username', None)
                email = getattr(user, 'email', None)
                retval.update({
                    'username': username,
                    'email': email
                })
            return retval

    if hasattr(request, 'user_id'):
        user_id_prop = request.user_id
        try:
            user_id = user_id_prop()
        except TypeError:
            user_id = user_id_prop

        if not user_id:
            return None
        return {'id': text(user_id)}
def _build_person_data ( request ) : if hasattr ( request , 'rollbar_person' ) : rollbar_person_prop = request . rollbar_person try : person = rollbar_person_prop ( ) except TypeError : person = rollbar_person_prop if person and isinstance ( person , dict ) : return person else : return None if hasattr ( request , 'user' ) : user_prop = request . user try : user = user_prop ( ) except TypeError : user = user_prop if not user : return None elif isinstance ( user , dict ) : return user else : retval = { } if getattr ( user , 'id' , None ) : retval [ 'id' ] = text ( user . id ) elif getattr ( user , 'user_id' , None ) : retval [ 'id' ] = text ( user . user_id ) # id is required, so only include username/email if we have an id if retval . get ( 'id' ) : username = getattr ( user , 'username' , None ) email = getattr ( user , 'email' , None ) retval . update ( { 'username' : username , 'email' : email } ) return retval if hasattr ( request , 'user_id' ) : user_id_prop = request . user_id try : user_id = user_id_prop ( ) except TypeError : user_id = user_id_prop if not user_id : return None return { 'id' : text ( user_id ) }
Returns a dictionary describing the logged-in user using data from `request.

    Try request.rollbar_person first, then 'user', then 'user_id'
Returns a dictionary describing the logged - in user using data from request .