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


Python Request.validated["user"]方法代码示例

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


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

示例1: validate_login_name

# 需要导入模块: from pyramid.request import Request [as 别名]
# 或者: from pyramid.request.Request import validated["user"] [as 别名]
def validate_login_name(context, request: Request):
    """Validate the user name of a login request.

    If valid and activated, the user object is added as 'user' to
    `request.validated`.
    """
    name = request.validated["name"]
    locator = request.registry.getMultiAdapter((context, request), IUserLocator)
    user = locator.get_user_by_login(name)
    if user is None:
        _add_no_such_user_or_wrong_password_error(request)
    else:
        request.validated["user"] = user
开发者ID:fhartwig,项目名称:adhocracy3.mercator,代码行数:15,代码来源:views.py

示例2: validate_login_email

# 需要导入模块: from pyramid.request import Request [as 别名]
# 或者: from pyramid.request.Request import validated["user"] [as 别名]
def validate_login_email(context, request: Request):
    """Validate the email address of a login request.

    If valid, the user object is added as 'user' to
    `request.validated`.
    """
    email = request.validated["email"]
    locator = request.registry.getMultiAdapter((context, request), IUserLocator)
    normalized_email = email.lower()
    user = locator.get_user_by_email(normalized_email)
    if user is None:
        _add_no_such_user_or_wrong_password_error(request)
    else:
        request.validated["user"] = user
开发者ID:fhartwig,项目名称:adhocracy3.mercator,代码行数:16,代码来源:views.py

示例3: validate_activation_path

# 需要导入模块: from pyramid.request import Request [as 别名]
# 或者: from pyramid.request.Request import validated["user"] [as 别名]
def validate_activation_path(context, request: Request):
    """Validate the user name of a login request.

    If valid and activated, the user object is added as 'user' to
    `request.validated`.
    """
    path = request.validated["path"]
    locator = request.registry.getMultiAdapter((context, request), IUserLocator)
    user = locator.get_user_by_activation_path(path)
    error = error_entry("body", "path", "Unknown or expired activation path")
    if user is None:
        request.errors.append(error)
    elif is_older_than(user, days=8):
        request.errors.append(error)
        user.activation_path = None
    else:
        user.activate()
        user.activation_path = None
        request.validated["user"] = user
        event = ResourceSheetModified(user, IUserBasic, request.registry, {}, {}, request)
        request.registry.notify(event)  # trigger reindex activation_path index
开发者ID:fhartwig,项目名称:adhocracy3.mercator,代码行数:23,代码来源:views.py


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