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


Python IRequest.validated方法代码示例

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


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

示例1: _validate_list_schema

# 需要导入模块: from pyramid.interfaces import IRequest [as 别名]
# 或者: from pyramid.interfaces.IRequest import validated [as 别名]
def _validate_list_schema(schema: SequenceSchema, cstruct: list,
                          request: IRequest, location='body'):
    if location != 'body':  # for now we only support location == body
        return
    child_cstructs = schema.cstruct_children(cstruct)
    try:
        request.validated = schema.deserialize(child_cstructs)
    except Invalid as err:
        _add_colander_invalid_error(err, request, location)
开发者ID:Janaba,项目名称:adhocracy3,代码行数:11,代码来源:schemas.py

示例2: _validate_request_data

# 需要导入模块: from pyramid.interfaces import IRequest [as 别名]
# 或者: from pyramid.interfaces.IRequest import validated [as 别名]
def _validate_request_data(context: IResource,
                           request: IRequest,
                           schema: colander.Schema):
    """Validate request data.

    :param context: passed to validator functions
    :param request: passed to validator functions
    :param schema: Schema to validate. Data to validate is extracted from the
                   request.body. For schema nodes with attribute `location` ==
                   `querystring` the data is extracted from the query string.
                   The validated data (dict or list) is stored in the
                   `request.validated` attribute.
    :raises HTTPBadRequest: HTTP 400 for bad request data.
    """
    body = {}
    if request.content_type == 'multipart/form-data':
        body = unflatten_multipart_request(request)
    if request.content_type == 'application/json':
        body = _extract_json_body(request)
    qs = _extract_querystring(request)
    _validate_body_or_querystring(body, qs, schema, context, request)
    if request.errors:
        request.validated = {}
        raise HTTPBadRequest()
开发者ID:Janaba,项目名称:adhocracy3,代码行数:26,代码来源:schemas.py


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