本文整理汇总了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'
示例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"
示例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)
示例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)
示例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")))