本文整理汇总了Python中market.contracts.Contract.get_contract_id方法的典型用法代码示例。如果您正苦于以下问题:Python Contract.get_contract_id方法的具体用法?Python Contract.get_contract_id怎么用?Python Contract.get_contract_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类market.contracts.Contract
的用法示例。
在下文中一共展示了Contract.get_contract_id方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete_contract
# 需要导入模块: from market.contracts import Contract [as 别名]
# 或者: from market.contracts.Contract import get_contract_id [as 别名]
def delete_contract(self, request):
if "id" in request.args:
c = Contract(hash_value=unhexlify(request.args["id"][0]))
for keyword in c.contract["vendor_offer"]["listing"]["item"]["keywords"]:
self.kserver.delete(keyword.lower(), c.get_contract_id(),
KeyChain().signing_key.sign(c.get_contract_id())[:64])
c.delete()
示例2: delete_contract
# 需要导入模块: from market.contracts import Contract [as 别名]
# 或者: from market.contracts.Contract import get_contract_id [as 别名]
def delete_contract(self, request):
try:
if "id" in request.args:
file_path = self.db.HashMap().get_file(request.args["id"][0])
with open(file_path, "r") as filename:
contract = json.load(filename, object_pairs_hook=OrderedDict)
c = Contract(self.db, contract=contract)
if "keywords" in c.contract["vendor_offer"]["listing"]["item"]:
for keyword in c.contract["vendor_offer"]["listing"]["item"]["keywords"]:
self.kserver.delete(
keyword.lower(),
c.get_contract_id(),
self.keychain.signing_key.sign(c.get_contract_id())[:64],
)
if "delete_images" in request.args:
c.delete(delete_images=True)
else:
c.delete()
request.write(json.dumps({"success": True}))
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
示例3: set_contract
# 需要导入模块: from market.contracts import Contract [as 别名]
# 或者: from market.contracts.Contract import get_contract_id [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
示例4: delete_contract
# 需要导入模块: from market.contracts import Contract [as 别名]
# 或者: from market.contracts.Contract import get_contract_id [as 别名]
def delete_contract(self, request):
try:
if "id" in request.args:
c = Contract(self.db, hash_value=unhexlify(request.args["id"][0]))
for keyword in c.contract["vendor_offer"]["listing"]["item"]["keywords"]:
self.kserver.delete(keyword.lower(), c.get_contract_id(),
self.keychain.signing_key.sign(c.get_contract_id())[:64])
c.delete()
request.write(json.dumps({"success": True}))
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
示例5: set_contract
# 需要导入模块: from market.contracts import Contract [as 别名]
# 或者: from market.contracts.Contract import get_contract_id [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())