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


Python User.fromName方法代码示例

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


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

示例1: apply_filter

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import fromName [as 别名]
def apply_filter(jsonData):
    user = User.fromName(session['uid'])
    filter_name = authenticate._get_filter_name_from_json(jsonData)
    filter_obj = user.filters.get(filter_name)
    if filter_obj is None:
        raise ValidationError(filter_name + ' is not a valid filter for this user')
    # fvs maps from id -> fv
    fvs = Datastore.cache[filter_obj['BuyMode']][filter_obj['SellMode']][str(filter_obj['HistoryDays'])]
    chosen = {}
    # Perform the filter
    for iid, fv in fvs.iteritems():
        # Filter for correct item type
        item_type = Datastore.item_types[int(float(fv.get('ItemType')))]
        if item_type not in filter_obj['Types']:
            continue
        # Filter for all bounds
        for f, finfo in filter_obj.get('Bounds').iteritems():
            fmax = finfo.get('Max')
            fmin = finfo.get('Min')
            if fmax is not None and fv.get(f) > fmax:
                continue
            if fmin is not None and fv.get(f) < fmin:
                continue
        # Add to map
        chosen[iid] = fv
    # TODO: Sort by specified sort type
    return ValidResponse(results=chosen)
开发者ID:rpindulic,项目名称:Quaggy,代码行数:29,代码来源:app.py

示例2: login

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import fromName [as 别名]
def login(jsonData):
    username, password = authenticate._get_user_and_pass_from_json(jsonData)
    user = User.fromName(username)
    if user is None or password is None or not user.verify_password(password):
        raise apiexceptions.InvalidCredentials()

    session['uid'] = user.name

    return ValidResponse(user=user.to_json())
开发者ID:rpindulic,项目名称:Quaggy,代码行数:11,代码来源:app.py

示例3: add_filter

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import fromName [as 别名]
def add_filter(jsonData):
    user = User.fromName(session['uid'])
    if request.method == 'POST':
        filters = authenticate._get_filters_from_json(jsonData)
        # Add each of these filters to our stored filters
        for name, fil in filters.iteritems():
            user.filters[name] = fil
        user.commit()
    return ValidResponse(filters=user.filters)
开发者ID:rpindulic,项目名称:Quaggy,代码行数:11,代码来源:app.py

示例4: signup

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import fromName [as 别名]
def signup(jsonData):
    username, password = authenticate._get_user_and_pass_from_json(jsonData)

    if User.fromName(username) is not None:
        raise apiexceptions.UserAlreadyExists()

    user = User.create()
    user.name = username
    user.set_password(password)
    user.commit()

    session['uid'] = user.name

    return ValidResponse(user=user.to_json())
开发者ID:rpindulic,项目名称:Quaggy,代码行数:16,代码来源:app.py


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