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


Python Client.post方法代码示例

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


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

示例1: test_view_any

# 需要导入模块: from webobtoolkit.client import Client [as 别名]
# 或者: from webobtoolkit.client.Client import post [as 别名]
def test_view_any():
    config = morepath.setup()
    app = morepath.App(testing_config=config)

    @app.path(path='')
    class Model(object):
        def __init__(self):
            pass

    @app.view(model=Model, request_method=morepath.ANY)
    def default(self, request):
        return "View"
    config.commit()

    c = Client(app)

    response = c.get('/')
    assert response.body == 'View'

    response = c.post('/')
    assert response.body == 'View'
开发者ID:reinout,项目名称:morepath,代码行数:23,代码来源:test_view_directive.py

示例2: test_view_predicates

# 需要导入模块: from webobtoolkit.client import Client [as 别名]
# 或者: from webobtoolkit.client.Client import post [as 别名]
def test_view_predicates():
    config = setup()
    app = App(testing_config=config)

    @app.path(path="")
    class Root(object):
        pass

    @app.view(model=Root, name="foo", request_method="GET")
    def get(self, request):
        return "GET"

    @app.view(model=Root, name="foo", request_method="POST")
    def post(self, request):
        return "POST"

    config.commit()

    c = Client(app)

    response = c.get("/foo")
    assert response.body == "GET"
    response = c.post("/foo")
    assert response.body == "POST"
开发者ID:reinout,项目名称:morepath,代码行数:26,代码来源:test_predicates.py

示例3: Client

# 需要导入模块: from webobtoolkit.client import Client [as 别名]
# 或者: from webobtoolkit.client.Client import post [as 别名]
"""
passing parameters as a form post
"""
from webobtoolkit.client import Client
client = Client()


def assert_success(request, response):
    """
    if response status != 200 then raise an error
    """

    if response.status_int != 200:
        raise Exception("Did not get a valid response from %s" % request.url)


print client.post("http://ajax.googleapis.com/ajax/services/search/web",
                  post=dict(v="1.0", q="define: HTTP"),
                  assert_=assert_success)
开发者ID:faassen,项目名称:webobtoolkit,代码行数:21,代码来源:responsepost.py

示例4: post

# 需要导入模块: from webobtoolkit.client import Client [as 别名]
# 或者: from webobtoolkit.client.Client import post [as 别名]
 def post(self, url, query_string=None, post={}, headers={}, files={}, status=None):
     kw = dict(query_string=query_string, headers=headers, post=post, files=files)
     kw["assert_"] = get_assert(status)
     return Client.post(self, url, **kw)
开发者ID:faassen,项目名称:webobtoolkit,代码行数:6,代码来源:testing.py

示例5: application

# 需要导入模块: from webobtoolkit.client import Client [as 别名]
# 或者: from webobtoolkit.client.Client import post [as 别名]
"""
uploading files example
"""
from webobtoolkit.client import Client, client_pipeline
from webob import Request, Response




def application(environ, start_response):
    """this application merely spits out the keys of the form that was
    posted. we are using webob Request and Response for brevity
    """
    request = Request(environ)
    return Response(str(request.POST.keys()))(environ, start_response)

client = Client(pipeline=client_pipeline(application))
print client.post("/", files=dict(file1=("myfile.txt",
                                    "this is a file containing this text")))
开发者ID:faassen,项目名称:webobtoolkit,代码行数:21,代码来源:responsefiles.py


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