Beispiel #1
0
def P_machine_delete(user_id, cb_sysname):
    session = get_session()
    with session.begin():
        P_machine_ref = P_machine_get_by_userid_(user_id,
                                                 cb_sysname,
                                                 session=session)
        if P_machine_ref:
            P_machine_ref.delete(session=session)
Beispiel #2
0
def P_machine_update(user_id, cb_sysname, values):
    session = get_session()
    with session.begin():
        P_machine_ref = P_machine_get_by_userid_(user_id,
                                                 cb_sysname,
                                                 session=session)
        P_machine_ref.update(values)
        P_machine_ref.save(session=session)
Beispiel #3
0
def count_insert_or_update(name, url):
    print name, url
    session = get_session()
    result = model_query(APICount, session=session). \
        filter_by(name=name). \
        filter_by(url=url). \
        first()
    if not result:
        with session.begin():
            result = APICount()
            result.update({'name': name, 'url': url, 'count': 1})
            result.save()
    else:
        result.count += 1
        result.save(session=session)
    return result
Beispiel #4
0
def service_update(service_id, values):
    session = get_session()
    with session.begin():
        service_ref = service_get(service_id, session=session)
        service_ref.update(values)
        service_ref.save(session=session)
Beispiel #5
0
 def save(self, session=None):
     """Save this object."""
     if not session:
         session = get_session()
     session.add(self)
     session.flush()