当前位置: 首页>>代码示例>>Python>>正文


Python Session.delete方法代码示例

本文整理汇总了Python中TrackerRestApi.Session.delete方法的典型用法代码示例。如果您正苦于以下问题:Python Session.delete方法的具体用法?Python Session.delete怎么用?Python Session.delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TrackerRestApi.Session的用法示例。


在下文中一共展示了Session.delete方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: delComment

# 需要导入模块: from TrackerRestApi import Session [as 别名]
# 或者: from TrackerRestApi.Session import delete [as 别名]
def delComment(user_id, group_id, id):

    session = Session()

    uid = int(current_user.get_id()) if app.config.get('LOGIN_DISABLED') is False else user_id

    t = session.query(association_table_user_group).filter(association_table_user_group.user_id == uid).\
                                                    filter(association_table_user_group.group_id == group_id).subquery('t')
    m = session.query(TrGroupComment).filter(TrGroupComment.user_group_id == t.c.id).\
                                        filter(TrGroupComment.id == id).first()

    if m is None:
        session.close()
        raise ServerError("Message doesn't exist.")

    try:
        session.delete(m)
        session.commit()
    except:
        session.rollback()
        raise ServerError("Can't delete message.")
    finally:
        session.close()

    return True
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:27,代码来源:group.py

示例2: delFavFeed

# 需要导入模块: from TrackerRestApi import Session [as 别名]
# 或者: from TrackerRestApi.Session import delete [as 别名]
def delFavFeed(user_id, feed_id, id):

    session = Session()

    uid = int(current_user.get_id()) if app.config.get('LOGIN_DISABLED') is False else user_id

    u_f = session.query(association_table_user_feed).filter_by(user_id=uid).filter_by(feed_id=feed_id).first()
    if u_f is None:
        session.close()
        raise ServerError("User or feed doesn't exist.")

    uf_fav = session.query(TrUserFeedFav).filter_by(uf_id=u_f.id).filter_by(feed_news_id=id).first()

    if uf_fav is not None:

        try:
            session.delete(uf_fav)
            session.commit()
        except:
            session.rollback()
            raise ServerError("Can't delete item from favorites.")
        finally:
            session.close()
    else:
        session.close()

    return True
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:29,代码来源:feed.py

示例3: delFollower

# 需要导入模块: from TrackerRestApi import Session [as 别名]
# 或者: from TrackerRestApi.Session import delete [as 别名]
def delFollower(user_id, follower_id):
    '''Delete follower by id'''

    session = Session()

    if session.query(TrUser).get(user_id) is None:
        raise ServerError("User does not exist")

    follower = session.query(TrFollower).filter_by(id=follower_id).first()

    try:
        session.delete(follower)
        session.commit()
    except:
        session.rollback()
        raise ServerError("Can't delete")
    finally:
        session.close()

    return True
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:22,代码来源:follower.py

示例4: delHelp

# 需要导入模块: from TrackerRestApi import Session [as 别名]
# 或者: from TrackerRestApi.Session import delete [as 别名]
def delHelp(user_id,vehicle_id):

    session = Session()

    v = session.query(TrVehicle).filter(TrVehicle.id == vehicle_id).filter(TrVehicle.user_id == user_id).first()

    if v is None:
        session.close()
        raise ServerError("Device doesn't exist.")

    if v.help is not None:
        try:
            session.delete(v.help)
            session.commit()
        except:
            session.rollback()
            raise ServerError("Can't delete")
        finally:
            session.close()

    return True
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:23,代码来源:help.py

示例5: delDGeo

# 需要导入模块: from TrackerRestApi import Session [as 别名]
# 或者: from TrackerRestApi.Session import delete [as 别名]
def delDGeo(user_id, id):

    session = Session()

    t = session.query(TrDevice.device_ID).filter(TrDevice.device_userID == user_id).subquery('t')
    geo = session.query(TrDGeozone).filter(TrDGeozone.device_id == t.c.device_ID).filter(TrDGeozone.id == id).first()

    if geo is None:
        session.close()
        raise ServerError("Geozone doesn't exist.")

    try:
        print 'delete geo %s' % geo.id
        session.delete(geo)
        session.commit()
    except:
        session.rollback()
        raise ServerError("Can't delete")
    finally:
        session.close()

    return True
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:24,代码来源:geo.py

示例6: delGroupMeeting

# 需要导入模块: from TrackerRestApi import Session [as 别名]
# 或者: from TrackerRestApi.Session import delete [as 别名]
def delGroupMeeting(user_id, id):

    session = Session()

    uid = int(current_user.get_id()) if app.config.get('LOGIN_DISABLED') is False else user_id

    t = session.query(TrGroup).filter(TrGroup.user_id == uid).subquery('t')
    m = session.query(TrGroupMeeting).filter(TrGroupMeeting.group_id == t.c.id).filter(TrGroupMeeting.id == id).first()
    if m is None:
        session.close()
        raise ServerError("Meeting doesn't exist.")

    try:
        session.delete(m)
        session.commit()
    except:
        session.rollback()
        raise ServerError("Can't delete meeting.")
    finally:
        session.close()

    return True
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:24,代码来源:group.py

示例7: delGroup

# 需要导入模块: from TrackerRestApi import Session [as 别名]
# 或者: from TrackerRestApi.Session import delete [as 别名]
def delGroup(user_id, id):

    session = Session()

    uid = int(current_user.get_id()) if app.config.get('LOGIN_DISABLED') is False else user_id

    g = session.query(TrGroup).filter(TrGroup.id == id).filter(TrGroup.user_id == uid).first()

    if g is None:
        session.close()
        raise ServerError("Group doesn't exist.")

    try:
        session.delete(g)
        session.commit()
    except:
        session.rollback()
        raise ServerError("Can't delete group.")
    finally:
        session.close()

    return True
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:24,代码来源:group.py

示例8: delDevice

# 需要导入模块: from TrackerRestApi import Session [as 别名]
# 或者: from TrackerRestApi.Session import delete [as 别名]
def delDevice(user_id, device_id):

    session = Session()

    uid = int(current_user.get_id()) if app.config.get('LOGIN_DISABLED') is False else user_id

    t = session.query(TrVehicle.id).filter(TrVehicle.user_id == uid).subquery('t')
    dev = session.query(TrDevice).filter(TrDevice.vehicle_id == t.c.id).filter(TrDevice.id == device_id).first()

    if dev is None:
        session.close()
        raise ServerError("Device doesn't exist.")

    try:
        session.delete(dev)
        session.commit()
    except:
        session.rollback()
        raise ServerError("Cannot delete device.")
    finally:
        session.close()

    return True
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:25,代码来源:device.py

示例9: delPlace

# 需要导入模块: from TrackerRestApi import Session [as 别名]
# 或者: from TrackerRestApi.Session import delete [as 别名]
def delPlace(user_id, place_id):

    session = Session()
    
    uid = int(current_user.get_id()) if app.config.get('LOGIN_DISABLED') is False else user_id

    p = session.query(TrPlace).filter(TrPlace.user_id == uid).filter(TrPlace.id == place_id).first()

    if p is None:
        session.close()
        raise ServerError("Place doesn't exist.")

    try:
        session.delete(p)
        session.commit()
    except:
        session.rollback()
        raise ServerError("Can't delete place.")
    finally:
        session.close()

    session.close()

    return True
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:26,代码来源:place.py


注:本文中的TrackerRestApi.Session.delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。