本文整理汇总了Python中market.contracts.Contract.create方法的典型用法代码示例。如果您正苦于以下问题:Python Contract.create方法的具体用法?Python Contract.create怎么用?Python Contract.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类market.contracts.Contract
的用法示例。
在下文中一共展示了Contract.create方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_contract
# 需要导入模块: from market.contracts import Contract [as 别名]
# 或者: from market.contracts.Contract import create [as 别名]
def set_contract(self, request):
print request
c = Contract()
c.create(
str(request.args["expiration_date"][0]),
request.args["metadata_category"][0],
request.args["title"][0],
request.args["description"][0],
request.args["currency_code"][0],
request.args["price"][0],
request.args["process_time"][0],
True if "nsfw" in request.args else False,
request.args["shipping_origin"][0],
request.args["ships_to"],
est_delivery_domestic=request.args["est_delivery_domestic"][0],
est_delivery_international=request.args["est_delivery_international"][0],
shipping_currency_code=request.args["shipping_currency_code"][0],
shipping_domestic=request.args["shipping_domestic"][0],
shipping_international=request.args["shipping_international"][0],
keywords=request.args["keywords"] if "keywords" in request.args else None,
category=request.args["category"][0] if request.args["category"][0] is not "" else None,
condition=request.args["condition"][0] if request.args["condition"][0] is not "" else None,
sku=request.args["sku"][0] if request.args["sku"][0] is not "" else None,
images=request.args["images"],
free_shipping=True if "free_shipping" in request.args else False)
for keyword in request.args["keywords"]:
self.kserver.set(keyword.lower(), c.get_contract_id(), self.kserver.node.getProto().SerializeToString())
示例2: set_contract
# 需要导入模块: from market.contracts import Contract [as 别名]
# 或者: from market.contracts.Contract import create [as 别名]
def set_contract(self, request):
try:
if "options" in request.args:
options = {}
for option in request.args["options"]:
options[option] = request.args[option]
c = Contract(self.db)
c.create(
str(request.args["expiration_date"][0]),
request.args["metadata_category"][0],
request.args["title"][0],
request.args["description"][0],
request.args["currency_code"][0],
request.args["price"][0],
request.args["process_time"][0],
str_to_bool(request.args["nsfw"][0]),
shipping_origin=request.args["shipping_origin"][0] if "shipping_origin" in request.args else None,
shipping_regions=request.args["ships_to"] if "ships_to" in request.args else None,
est_delivery_domestic=request.args["est_delivery_domestic"][0]
if "est_delivery_domestic" in request.args
else None,
est_delivery_international=request.args["est_delivery_international"][0]
if "est_delivery_international" in request.args
else None,
terms_conditions=request.args["terms_conditions"][0]
if request.args["terms_conditions"][0] is not ""
else None,
returns=request.args["returns"][0] if request.args["returns"][0] is not "" else None,
shipping_currency_code=request.args["shipping_currency_code"][0],
shipping_domestic=request.args["shipping_domestic"][0],
shipping_international=request.args["shipping_international"][0],
keywords=request.args["keywords"] if "keywords" in request.args else None,
category=request.args["category"][0] if request.args["category"][0] is not "" else None,
condition=request.args["condition"][0] if request.args["condition"][0] is not "" else None,
sku=request.args["sku"][0] if request.args["sku"][0] is not "" else None,
images=request.args["images"],
free_shipping=str_to_bool(request.args["free_shipping"][0]),
options=options if "options" in request.args else None,
moderators=request.args["moderators"] if "moderators" in request.args else None,
)
for keyword in request.args["keywords"]:
self.kserver.set(
digest(keyword.lower()), c.get_contract_id(), self.kserver.node.getProto().SerializeToString()
)
request.write(json.dumps({"success": True, "id": c.get_contract_id().encode("hex")}))
request.finish()
return server.NOT_DONE_YET
except Exception, e:
request.write(json.dumps({"success": False, "reason": e.message}, indent=4))
request.finish()
return server.NOT_DONE_YET