def job_create(context, values): mains = values.pop("mains", []) libs = values.pop("libs", []) interface = values.pop("interface", []) session = get_session() try: with session.begin(): job = m.Job() job.update(values) # These are 'lazy' objects. The initialization below # is needed here because it provides libs, mains, and # interface to be initialized within a session even if # the lists are empty job.mains = [] job.libs = [] job.interface = [] _append_job_binaries(context, session, mains, job.mains) _append_job_binaries(context, session, libs, job.libs) _append_interface(context, interface, job.interface) session.add(job) except db_exc.DBDuplicateEntry as e: raise ex.DBDuplicateEntry(_("Duplicate entry for Job: %s") % e.columns) return job
def job_create(context, values): mains = values.pop("mains", []) libs = values.pop("libs", []) session = get_session() with session.begin(): job = m.Job() job.update(values) # libs and mains are 'lazy' objects. The initialization below # is needed here because it provides libs and mains to be initialized # within a session even if the lists are empty job.mains = [] job.libs = [] try: _append_job_binaries(context, session, mains, job.mains) _append_job_binaries(context, session, libs, job.libs) job.save(session=session) except db_exc.DBDuplicateEntry as e: raise ex.DBDuplicateEntry( _("Duplicate entry for Job: %s") % e.columns) return job