def get_roles(user, obj):
    # get roles for the user, if present:
    roles = cache.get(roles_key(user, obj))
    if isinstance(roles, list):
        # Cache hit (a miss returns NoneType rather than an empty list)
        return roles
    else:
        # we need to recompute roles for this model
        user_roles = []
        if not hasattr(obj, 'relevant_roles'):
            raise RulesException(
                'Cannot build roles cache for %s instance. Did you forget to \
                define a "relevant_roles()" method on %s?' % (obj.__class__,
                                                              obj.__class__))

        relevant = obj.relevant_roles()
        for role in relevant:
            if role.is_member(user, obj):
                user_roles.append(role)
        cache.set(roles_key(user, obj), user_roles, 1*HOUR)
        return user_roles
Creates a new Measurement, see openhtf.PhaseInfo.WithArgs.
dataset/ETHPy150Open chrisglass/django-rulez/rulez/rolez/cache_helper.py/get_roles--crossover with--dataset/ETHPy150Open google/openhtf/openhtf/util/measurements.py/Measurement.WithArgs