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


Python Processor.args方法代码示例

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


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

示例1: test_getMultiFormatedResource

# 需要导入模块: from seishub.core.processor import Processor [as 别名]
# 或者: from seishub.core.processor.Processor import args [as 别名]
 def test_getMultiFormatedResource(self):
     """
     Get resource in a certain format using multiple style sheets.
     """
     proc = Processor(self.env)
     # create resource
     proc.run(POST, '/transformation-test/rt/test.xml', StringIO(XML_DOC))
     # transform using a format chain
     proc.args = {'format': ['xml2html', 'html2txt']}
     res = proc.run(GET, '/transformation-test/rt/test.xml')
     data = res.render(proc)
     self.assertEquals(data, TXT_DOC)
     # missing formats
     proc.args = {'format': ['XXX', 'YYY', 'ZZZ']}
     res = proc.run(GET, '/transformation-test/rt/test.xml')
     data = res.render(proc)
     self.assertEquals(data, XML_DOC)
     # one valid format
     proc.args = {'format': ['XXX', 'xml2html', 'YYY']}
     res = proc.run(GET, '/transformation-test/rt/test.xml')
     data = res.render(proc)
     self.assertEquals(data, HTML_DOC)
     # transform using a format chain but last style sheet is missing
     proc.args = {'format': ['xml2html', 'html2txt', 'XXX']}
     res = proc.run(GET, '/transformation-test/rt/test.xml')
     data = res.render(proc)
     self.assertEquals(data, TXT_DOC)
     # transform using a format chain but one style sheet is missing
     proc.args = {'format': ['xml2html', 'XXX', 'html2txt']}
     res = proc.run(GET, '/transformation-test/rt/test.xml')
     data = res.render(proc)
     self.assertEquals(data, TXT_DOC)
     # delete resource
     proc.run(DELETE, '/transformation-test/rt/test.xml')
开发者ID:barsch,项目名称:seishub.core,代码行数:36,代码来源:test_rest_transformation.py

示例2: test_getFormatedResource

# 需要导入模块: from seishub.core.processor import Processor [as 别名]
# 或者: from seishub.core.processor.Processor import args [as 别名]
 def test_getFormatedResource(self):
     """
     Get resource in a certain format using a single style sheet.
     """
     proc = Processor(self.env)
     # create resource
     proc.run(POST, '/transformation-test/rt/test.xml', StringIO(XML_DOC))
     # without format
     proc.args = {'format': []}
     res = proc.run(GET, '/transformation-test/rt/test.xml')
     data = res.render(proc)
     self.assertEquals(data, XML_DOC)
     # transform to existing format HTML
     proc.args = {'format': ['xml2html']}
     res = proc.run(GET, '/transformation-test/rt/test.xml')
     data = res.render(proc)
     self.assertEquals(data, HTML_DOC)
     # transform to existing format SVG
     proc.args = {'format': ['xml2svg']}
     res = proc.run(GET, '/transformation-test/rt/test.xml')
     data = res.render(proc)
     self.assertEquals(data, SVG_DOC)
     # missing format
     proc.args = {'format': ['XXX']}
     res = proc.run(GET, '/transformation-test/rt/test.xml')
     data = res.render(proc)
     self.assertEquals(data, XML_DOC)
     # delete resource
     proc.run(DELETE, '/transformation-test/rt/test.xml')
开发者ID:barsch,项目名称:seishub.core,代码行数:31,代码来源:test_rest_transformation.py

示例3: test_putFormatedResource

# 需要导入模块: from seishub.core.processor import Processor [as 别名]
# 或者: from seishub.core.processor.Processor import args [as 别名]
 def test_putFormatedResource(self):
     """
     Upload resource in a certain format using a single style sheets.
     """
     proc = Processor(self.env)
     # create + transform resource
     proc.args = {'format': ['xml2html']}
     proc.run(POST, '/transformation-test/rt/test.xml', StringIO(XML_DOC))
     # get uploaded resource
     proc.args = {}
     res = proc.run(GET, '/transformation-test/rt/test.xml')
     data = res.render(proc)
     self.assertEquals(data, HTML_DOC.strip())
     # get uploaded resource with format
     proc.args = {'format': ['html2txt']}
     res = proc.run(GET, '/transformation-test/rt/test.xml')
     data = res.render(proc)
     self.assertEquals(data, TXT_DOC)
     # delete resource
     proc.run(DELETE, '/transformation-test/rt/test.xml')
开发者ID:barsch,项目名称:seishub.core,代码行数:22,代码来源:test_rest_transformation.py

示例4: test_postMultiFormatedResource

# 需要导入模块: from seishub.core.processor import Processor [as 别名]
# 或者: from seishub.core.processor.Processor import args [as 别名]
 def test_postMultiFormatedResource(self):
     """
     Update resource in a certain format using multiple style sheets.
     """
     proc = Processor(self.env)
     # create resource
     proc.run(POST, '/transformation-test/rt/test.xml', StringIO(XML_DOC))
     # update resource with transformation
     proc.args = {'format': ['xml2html', 'html2xml']}
     proc.run(PUT, '/transformation-test/rt/test.xml', StringIO(XML_DOC))
     # get uploaded resource
     proc.args = {}
     res = proc.run(GET, '/transformation-test/rt/test.xml')
     data = res.render(proc)
     self.assertEquals(data, XML_DOC_2)
     # get uploaded resource with format
     proc.args = {'format': ['xml2html', 'html2txt']}
     res = proc.run(GET, '/transformation-test/rt/test.xml')
     data = res.render(proc)
     self.assertEquals(data, 'Sales Results By Division\n\n')
     # delete resource
     proc.run(DELETE, '/transformation-test/rt/test.xml')
开发者ID:barsch,项目名称:seishub.core,代码行数:24,代码来源:test_rest_transformation.py

示例5: _send_request

# 需要导入模块: from seishub.core.processor import Processor [as 别名]
# 或者: from seishub.core.processor.Processor import args [as 别名]
    def _send_request(self, method, url, file_or_fileobject=None, args=None):
        """
        Uploads a file with the given method to the given url.

        :type method: string
        :param method: GET, POST, PUT, or DELETE
        :type url: string
        :param url: The url to upload to
        :type file_or_fileobject: string or file-like object
        :param file_or_fileobject: The file or file like object to upload. If
            None, then nothing will be uploaded.
        :type args: dictionary
        :param args: The arguments of the request. This is the same as any
        parameters appended to the URL.


        file_or_fileobject can be either a StringIO with some data or a
        filename.

        Returns the respone from the request.
        """
        if method.upper() == "GET":
            method = GET
        elif method.upper() == "POST":
            method = POST
        elif method.upper() == "PUT":
            method = PUT
        elif method.upper() == "DELETE":
            method = DELETE
        else:
            msg = "Unknown method '%s'." % method
            raise ValueError(msg)

        proc = Processor(self.env)
        # Append potential arguments.
        if args:
            # Convert everything to strings. The processor usually deals with
            # URL where everything is a string by default.
            proc.args = {key: [str(value)] for (key, value) in
                args.iteritems()}
        if file_or_fileobject:
            if not hasattr(file_or_fileobject, "read") or \
                    not hasattr(file_or_fileobject, "seek"):
                with open(file_or_fileobject, "r") as open_file:
                    file_or_fileobject = StringIO.StringIO(open_file.read())
        else:
            file_or_fileobject = None
        response = proc.run(method, url, file_or_fileobject)
        if method == "GET" and hasattr(response, "render_GET"):

            class dummy(object):
                pass
            dum = dummy()
            dum.args = {}
            dum.env = dummy()
            dum.env.auth = dummy()
            temp = dummy()
            temp.permissions = 755
            dum.env.auth.getUser = lambda x: temp

            return self._strip_xml_declaration(response.render_GET(dum))
        return response
开发者ID:krischer,项目名称:seishub.plugins.event_based_data,代码行数:64,代码来源:test_case.py


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