本文整理匯總了Python中api_functions.CronosDB.get_actor_by_id方法的典型用法代碼示例。如果您正苦於以下問題:Python CronosDB.get_actor_by_id方法的具體用法?Python CronosDB.get_actor_by_id怎麽用?Python CronosDB.get_actor_by_id使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類api_functions.CronosDB
的用法示例。
在下文中一共展示了CronosDB.get_actor_by_id方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: update_actor
# 需要導入模塊: from api_functions import CronosDB [as 別名]
# 或者: from api_functions.CronosDB import get_actor_by_id [as 別名]
def update_actor(actor_id):
response.headers['Content-Type'] = 'application/json'
db = CronosDB("root", "zerl", "cronos")
try:
try:
data = json.load(request.body)
except Exception as error:
raise ValueError("Cannot parse request: {0}".format(error))
if data is None:
raise ValueError("Request is None")
if not db.update_actor(actor_id, data["name"], data["nationality"], data["birth_date"]):
raise ValueError("Cannot update actor {0}-{1}".format(actor_id, data["name"]))
return json.dumps(db.get_actor_by_id(actor_id))
except ValueError as error:
msg = "Exception...{0}".format(error)
response.status = 400
print msg
return json.dumps({"status": 400, "msg": msg})
示例2: show_actor_by_id
# 需要導入模塊: from api_functions import CronosDB [as 別名]
# 或者: from api_functions.CronosDB import get_actor_by_id [as 別名]
def show_actor_by_id(actor_id):
db = CronosDB("root", "zerl", "cronos")
response.headers['Content-Type'] = 'application/json'
return json.dumps(db.get_actor_by_id(actor_id))