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


Python Session.refresh方法代码示例

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


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

示例1: getCode

# 需要导入模块: from TrackerRestApi import Session [as 别名]
# 或者: from TrackerRestApi.Session import refresh [as 别名]
def getCode(number):

    session = Session()

    sms = SmsEpochta()
    code = ''.join(random.choice(string.digits) for _ in range(app.config.get('SMS_CODE_LEN')))

    u = session.query(TrUser).filter(TrUser.login == number).first()

    if u is None:
        u = TrUser(login=number, auth_code=code, active='N')
        session.add(u)
    else:
        setattr(u, 'auth_code', code)
        setattr(u, 'active', 'N')
        session.merge(u)

    try:
        session.commit()
        session.refresh(u)
    except:
        session.rollback()
        raise ServerError("Can't generate new code.")
    finally:
        session.close()

    sms.send(number, code)

    return u.id
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:31,代码来源:auth.py

示例2: addComment

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

    session = Session()

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

    ug = session.query(association_table_user_group).filter(association_table_user_group.user_id == uid).\
                                                    filter(association_table_user_group.group_id == group_id).first()
    if ug is None:
        session.close()
        raise ServerError("Group doesn't exist.")

    gm = TrGroupComment(message, ug.id)

    try:
        session.add(gm)
        session.commit()
        session.refresh(gm)
    except:
        session.rollback()
        raise ServerError("Can't add message.")
    finally:
        session.close()

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

示例3: addPlace

# 需要导入模块: from TrackerRestApi import Session [as 别名]
# 或者: from TrackerRestApi.Session import refresh [as 别名]
def addPlace(user_id, title, longitude, latitude, type, desc):

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

    p = TrPlace(user_id=uid, title=title, longitude=float(longitude), latitude=float(latitude), type=type, desc=desc)

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

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

示例4: addGroup

# 需要导入模块: from TrackerRestApi import Session [as 别名]
# 或者: from TrackerRestApi.Session import refresh [as 别名]
def addGroup(user_id, title, desc, invitation, meeting, help):

    session = Session()

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

    g = TrGroup(title=title, desc=desc, invitation=invitation, meeting=meeting, help=help, user_id=uid)

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

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

示例5: addGroupMeeting

# 需要导入模块: from TrackerRestApi import Session [as 别名]
# 或者: from TrackerRestApi.Session import refresh [as 别名]
def addGroupMeeting(user_id, group_id, title, lat_log, time):

    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.user_id == uid).filter(TrGroup.id == group_id).first()
    if g is None:
        session.close()
        raise ServerError("Group doesn't exist.")

    m = TrGroupMeeting(group_id=group_id, title=title, latitude=0, longitude=0, time=datetime.datetime.fromtimestamp(time))

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

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


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