'If this mapper is to be a primary mapper (i.e. the
non_primary flag is not set), associate this Mapper with the
given class_ and entity name.
Subsequent calls to ``class_mapper()`` for the class_/entity
name combination will return this mapper.  Also decorate the
`__init__` method on the mapped class to include optional
auto-session attachment logic.'

def _configure_class_instrumentation(self):

    manager = attributes.manager_of_class(self.class_)
    if self.non_primary:
        if ((not manager) or (not manager.is_mapped)):
            raise sa_exc.InvalidRequestError(('Class    %s    has    no    primary    mapper    configured.        Configure    a    primary    mapper    first    before    setting    up    a    non    primary    Mapper.' % self.class_))
        self.class_manager = manager
        self._identity_class = manager.mapper._identity_class
        _mapper_registry[self] = True
        return
    if (manager is not None):
        assert (manager.class_ is self.class_)
        if manager.is_mapped:
            raise sa_exc.ArgumentError(("Class    '%s'    already    has    a    primary    mapper    defined.    Use    non_primary=True    to    create    a    non    primary    Mapper.        clear_mappers()    will    remove    *all*    current    mappers    from    all    classes." % self.class_))
    _mapper_registry[self] = True
    self.dispatch.instrument_class(self, self.class_)
    if (manager is None):
        manager = instrumentation.register_class(self.class_)
    self.class_manager = manager
    manager.mapper = self
    manager.deferred_scalar_loader = util.partial(loading.load_scalar_attributes, self)
    if manager.info.get(_INSTRUMENTOR, False):
        return
    event.listen(manager, 'first_init', _event_on_first_init, raw=True)
    event.listen(manager, 'init', _event_on_init, raw=True)
    event.listen(manager, 'resurrect', _event_on_resurrect, raw=True)
    for (key, method) in util.iterate_attributes(self.class_):
        if isinstance(method, types.FunctionType):
            if hasattr(method, '__sa_reconstructor__'):
                self._reconstructor = method
                event.listen(manager, 'load', _event_on_load, raw=True)
            elif hasattr(method, '__sa_validators__'):
                validation_opts = method.__sa_validation_opts__
                for name in method.__sa_validators__:
                    self.validators = self.validators.union({name: (method, validation_opts)})
    manager.info[_INSTRUMENTOR] = self
