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


Python Response.call_on_close方法代码示例

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


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

示例1: _parse_and_execute

# 需要导入模块: from werkzeug.wrappers import Response [as 别名]
# 或者: from werkzeug.wrappers.Response import call_on_close [as 别名]
    def _parse_and_execute(self, process, wps_request, uuid):
        """Parse and execute request
        """
        LOGGER.debug('Checking if datainputs is required and has been passed')
        if process.inputs:
            if wps_request.inputs is None:
                raise MissingParameterValue('', 'datainputs')

        LOGGER.debug('Checking if all mandatory inputs have been passed')
        data_inputs = {}
        for inpt in process.inputs:
            if inpt.identifier not in wps_request.inputs:
                if inpt.min_occurs > 0:
                    LOGGER.error('Missing parameter value: %s', inpt.identifier)
                    raise MissingParameterValue(
                        inpt.identifier, inpt.identifier)
                else:
                    inputs = deque(maxlen=inpt.max_occurs)
                    inputs.append(inpt.clone())
                    data_inputs[inpt.identifier] = inputs

            # Replace the dicts with the dict of Literal/Complex inputs
            # set the input to the type defined in the process
            if isinstance(inpt, ComplexInput):
                data_inputs[inpt.identifier] = self.create_complex_inputs(
                    inpt, wps_request.inputs[inpt.identifier])
            elif isinstance(inpt, LiteralInput):
                data_inputs[inpt.identifier] = self.create_literal_inputs(
                    inpt, wps_request.inputs[inpt.identifier])
            elif isinstance(inpt, BoundingBoxInput):
                data_inputs[inpt.identifier] = self.create_bbox_inputs(
                    inpt, wps_request.inputs[inpt.identifier])

        wps_request.inputs = data_inputs

        # set as_reference to True for all the outputs specified as reference
        # if the output is not required to be raw
        if not wps_request.raw:
            for wps_outpt in wps_request.outputs:

                is_reference = wps_request.outputs[
                    wps_outpt].get('asReference', 'false')
                if is_reference.lower() == 'true':
                    # check if store is supported
                    if process.store_supported == 'false':
                        raise StorageNotSupported(
                            'The storage of data is not supported for this process.')

                    is_reference = True
                else:
                    is_reference = False

                for outpt in process.outputs:
                    if outpt.identifier == wps_outpt:
                        outpt.as_reference = is_reference

        # catch error generated by process code
        try:
            wps_response = process.execute(wps_request, uuid)
        except Exception as e:
            if not isinstance(e, NoApplicableCode):
                raise NoApplicableCode('Service error: %s' % e)
            raise e

        # get the specified output as raw
        if wps_request.raw:
            for outpt in wps_request.outputs:
                for proc_outpt in process.outputs:
                    if outpt == proc_outpt.identifier:
                        resp = Response(proc_outpt.data)
                        resp.call_on_close(process.clean)
                        return resp

            # if the specified identifier was not found raise error
            raise InvalidParameterValue('')

        return wps_response
开发者ID:sebastic,项目名称:pywps,代码行数:79,代码来源:Service.py


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