def register(self, model, **attr):
        """Register a model or a table with this mapper

        :param model: a table or a :class:`.BaseModel` class
        :return: a Model class or a table
        """
        metadata = self.metadata
        if not isinstance(model, Table):
            model_name = self._create_model(model, **attr)
            if not model_name:
                return
            model, name = model_name
            table = model.__table__
            self._declarative_register[name] = model

            if name in self._bases:
                for model in self._bases.pop(name):
                    self.register(model)
        else:
            table = model.tometadata(metadata)
            model = table

        # Register engine
        engine = None
        label = table.info.get('bind_label')
        keys = ('%s.%s' % (label, table.key),
                label, None) if label else (None,)
        #
        # Find the engine for this table
        for key in keys:
            engine = self.get_engine(key)
            if engine:
                break
        assert engine
        self.binds[table] = engine

        return model