def data_source_create(context, values): data_source = m.DataSource() data_source.update(values) try: data_source.save() except db_exc.DBDuplicateEntry as e: raise ex.DBDuplicateEntry("Duplicate entry for DataSource: %s" % e.columns) return data_source
def data_source_create(context, values): data_source = m.DataSource() data_source.update(values) session = get_session() with session.begin(): try: data_source.save(session=session) except db_exc.DBDuplicateEntry as e: raise ex.DBDuplicateEntry( _("Duplicate entry for DataSource: %s") % e.columns) return data_source