code: def __configure_roles(mapper, cls):
      
      # Don't mutate ``__roles__`` in the base class.
      # The subclass must have its own.
      # Since classes may specify ``__roles__`` directly without
      # using :func:`with_roles`, we must preserve existing content.
      if '__roles__' not in cls.__dict__:
          # If the following line is confusing, it's because reading an
          # attribute on an object invokes the Method Resolution Order (MRO)
          # mechanism to find it on base classes, while writing always writes
          # to the current object.
          cls.__roles__ = deepcopy(cls.__roles__)
  
      # An attribute may be defined more than once in base classes. Only handle the first
      processed = set()
  
      # Loop through all attributes in this and base classes, looking for role annotations
      for base in cls.__mro__:
          for name, attr in base.__dict__.items():
              if name in processed or name.startswith('__'):
                  continue
  
              if isinstance(attr, collections.Hashable) and attr in __cache__:
                  data = __cache__[attr]
                  del __cache__[attr]
              elif isinstance(attr, InstrumentedAttribute) and attr.property in __cache__:
                  data = __cache__[attr.property]
                  del __cache__[attr.property]
              elif hasattr(attr, '_coaster_roles'):
                  data = attr._coaster_roles
              else:
                  data = None
              if data is not None:
                  for role in data.get('call', []):
                      cls.__roles__.setdefault(role, {}).setdefault('call', set()).add(name)
                  for role in data.get('read', []):
                      cls.__roles__.setdefault(role, {}).setdefault('read', set()).add(name)
                  for role in data.get('write', []):
                      cls.__roles__.setdefault(role, {}).setdefault('write', set()).add(name)
                  processed.add(name)
docs: Run through attributes of the class looking for role decorations from
      :func:`with_roles` and add them to :attr:`cls.__roles__`