code: def add_all(cls, models, commit=True, check_type=False):
          if check_type:
              for model in models:
                  if not isinstance(model, cls):
                      raise ValueError('%s is not of type %s' (model, cls))
          if None in models:
              cls.session.add_all([m for m in models if m is not None])
          else:
              cls.session.add_all(models)
          try:
              if commit:
                  cls.session.commit()
              return models
          except:
              cls.session.rollback()
              raise