Esempio n. 1
0
def commit(user, pid, comment, xml):
    connect = MySQLdb.connect(db=config.DB_NAME, host=config.DB_HOST, port=config.DB_PORT, user=config.DB_USER, passwd=config.DB_PASSWD)
    cur = connect.cursor()
    cur.execute('SELECT id,name,xml,metamodel_id,rep_id FROM ProjectInfo WHERE id=%s;', (pid,))
    rows = cur.fetchall()
    if len(rows) == 0:
        cur.close()
        connect.close()
        return 0
    #xml to rep (xml include version infomation)
    rep_id = rows[0][4]
    model_json = rows[0][2]
    cur.close()
    connect.close()
    return CommitService.commit(rep_id, xml, comment)
Esempio n. 2
0
def import_to_rep(user, xml, rep_id):
    model = clearmodel(json.loads(xml))
    return CommitService.commit(rep_id, json.dumps(model), 'import')