本文整理汇总了Python中myapp.ApiObject.ApiObject.write_json_core方法的典型用法代码示例。如果您正苦于以下问题:Python ApiObject.write_json_core方法的具体用法?Python ApiObject.write_json_core怎么用?Python ApiObject.write_json_core使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类myapp.ApiObject.ApiObject
的用法示例。
在下文中一共展示了ApiObject.write_json_core方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from myapp.ApiObject import ApiObject [as 别名]
# 或者: from myapp.ApiObject.ApiObject import write_json_core [as 别名]
def post(self):
SetUtf8.set()
page=None
if(self.request.get("page")):
page=self.request.get("page")
user = users.get_current_user()
if(not user):
if(page=="update"):
dic={"status":"failed","message":"アプリを登録するにはログインする必要があります。"}
ApiObject.write_json_core(self,dic)
return
else:
self.response.out.write(Alert.alert_msg("アプリを登録するにはログインする必要があります。",self.request.host))
return
if(page=="update"):
dic=DevPortal.update_app(self,user)
if(dic==None):
return
ApiObject.write_json_core(self,dic)
return
if(page=="submit"):
if(not DevPortal.add_new_app(self,user)):
return
DevPortal.ret(self,"top")
示例2: get
# 需要导入模块: from myapp.ApiObject import ApiObject [as 别名]
# 或者: from myapp.ApiObject.ApiObject import write_json_core [as 别名]
def get(self):
#日本語対応
SetUtf8.set()
if(ApiObject.check_api_capacity(self)):
return
dic=ApiBookmark.get_core(self)
ApiObject.write_json_core(self,dic)
示例3: post_snapshot
# 需要导入模块: from myapp.ApiObject import ApiObject [as 别名]
# 或者: from myapp.ApiObject.ApiObject import write_json_core [as 别名]
def post_snapshot(self):
key=self.request.get("key")
snap_shot_0=self.request.get("snap_shot_0")
snap_shot_1=self.request.get("snap_shot_1")
thumbnail=self.request.get("thumbnail")
snap_range=int(self.request.get("snap_range"))
try:
db.run_in_transaction(Chat.post_snapshot_core,key,snap_shot_0,snap_shot_1,snap_range,thumbnail)
ApiObject.write_json_core(self,{"status":"success"})
except:
ApiObject.write_json_core(self,{"status":"failed"})
示例4: post_command
# 需要导入模块: from myapp.ApiObject import ApiObject [as 别名]
# 或者: from myapp.ApiObject.ApiObject import write_json_core [as 别名]
def post_command(self):
key=self.request.get("key")
cmd_count=int(self.request.get("command_count"))
user_count=int(self.request.get("user_count"))
client_id=self.request.get("client_id")
cmd_list=""
for i in range(0,cmd_count):
cmd=self.request.get("command"+str(i))
if(not cmd):
cmd_list=None
break
cmd_list=cmd_list+cmd
if(i!=cmd_count-1):
cmd_list=cmd_list+" , "
#if(not cmd_list):
# ApiObject.write_json_core(self,{"status":"failed"})
# return
try:
size=db.run_in_transaction(Chat.post_command_core,key,cmd_list,cmd_count,user_count,client_id) #排他制御を行う
if(size==Chat.ERROR_NO_ROOM):
ApiObject.write_json_core(self,{"status":"not_found"})
else:
if(size==Chat.ERROR_DISCONNECT):
ApiObject.write_json_core(self,{"status":"disconnect"})
else:
ApiObject.write_json_core(self,{"status":"success","size":size})
except:
ApiObject.write_json_core(self,{"status":"failed"})
示例5: get
# 需要导入模块: from myapp.ApiObject import ApiObject [as 别名]
# 或者: from myapp.ApiObject.ApiObject import write_json_core [as 别名]
def get(self):
SetUtf8.set()
#Query文字列を取得
query=self.request.query_string;
#RESULT
result_dic={}
request_no=0
#APIリクエストに分解
api_list=query.split(":")
for api in api_list:
#APIの引数を取得
args=api.split("&")
#引数をDictionaryに分解
api_args={}
for arg in args:
params=arg.split("=")
if(len(params)>=2):
api_args[params[0]]=params[1]
#呼び出しAPIのクラス名を決定
if(api_args.has_key("class")):
#ダミーリクエストハンドラーを作成
req=HttpHandlerHook()
req.request.args=api_args
req.request.host=self.request.host
#API呼び出し
dic=None
if(api_args["class"]=="api_bookmark"):
dic=ApiBookmark.get_core(req)
if(api_args["class"]=="api_user"):
dic=ApiUser.get_core(req)
if(api_args["class"]=="api_feed"):
dic=ApiFeed.get_core(req)
if(dic==None):
logging.error("UnknownClass:"+api_args["class"])
else:
result_dic["request"+str(request_no)]=dic
request_no=request_no+1
ApiObject.write_json_core(self,result_dic)
示例6: post
# 需要导入模块: from myapp.ApiObject import ApiObject [as 别名]
# 或者: from myapp.ApiObject.ApiObject import write_json_core [as 别名]
def post(self):
# 日本語対応
SetUtf8.set()
if ApiObject.check_api_capacity(self):
return
# パラメータ取得
method = ""
if self.request.get("method"):
method = self.request.get("method")
# 返り値
dic = {"status": "failed", "message": "methodが見つかりません"}
# ユーザクラス
if method == "putData":
dic = ApiPerpetuation.put_data(self)
ApiObject.write_json_core(self, dic)
示例7: get_command
# 需要导入模块: from myapp.ApiObject import ApiObject [as 别名]
# 或者: from myapp.ApiObject.ApiObject import write_json_core [as 别名]
def get_command(self):
try:
room=ChatRoom.get(self.request.get("key"))#db.get(str(self.request.get("key")))
except:
ApiObject.write_json_core(self,{"status":"failed"})
return
if(room==None):
ApiObject.write_json_core(self,{"status":"not_found"})
return
client_id=self.request.get("client_id")
if(not(client_id in room.channel_client_list)):
ApiObject.write_json_core(self,{"status":"disconnect"})
return
try:
offset=int(self.request.get("offset"))
except:
ApiObject.write_json_core(self,{"status":"offset_overflow"})
return
limit=int(self.request.get("limit"))
now_len=room.command_cnt
if (offset+limit)>now_len:
limit=now_len-offset
server_command_list=room.command_list.split(" , ")
command_list=[]
for i in range(offset,offset+limit):
if(i<room.snap_range):
cmd_nop=4
nop_command="[{'cmd':"+str(cmd_nop)+"}]";
command_list.append(nop_command)
else:
one_cmd=server_command_list[i-room.snap_range]
command_list.append(one_cmd)
ApiObject.write_json_core(self,{"status":"success","offset":offset,"count":limit,"command_list":command_list})
示例8: get_snap_shot
# 需要导入模块: from myapp.ApiObject import ApiObject [as 别名]
# 或者: from myapp.ApiObject.ApiObject import write_json_core [as 别名]
def get_snap_shot(self):
try:
room=ChatRoom.get(self.request.get("key"))#db.get(str(self.request.get("key")))
except:
ApiObject.write_json_core(self,{"status":"failed"})
return
if(room==None):
ApiObject.write_json_core(self,{"status":"not_found"})
return
ApiObject.write_json_core(self,{"status":"success","snap_shot_0":room.snap_shot_0,"snap_shot_1":room.snap_shot_1,"snap_range":room.snap_range})
示例9: get_user_list
# 需要导入模块: from myapp.ApiObject import ApiObject [as 别名]
# 或者: from myapp.ApiObject.ApiObject import write_json_core [as 别名]
def get_user_list(self):
try:
room=ChatRoom.get(self.request.get("key"))#db.get(str(self.request.get("key")))
except:
ApiObject.write_json_core(self,{"status":"failed"})
return
if(room==None):
ApiObject.write_json_core(self,{"status":"not_found"})
return
dic={}
for client in room.channel_client_list:
user_id=client.split("_")[0]
name="unknown"
bookmark=ApiObject.get_bookmark_of_user_id(user_id)
if(bookmark):
name=bookmark.name
name=str(client.split("_")[2]).replace("-","%")
name=urllib.unquote_plus(name)
dic[client]=name
ApiObject.write_json_core(self,{"status":"success","user_list":dic});
示例10: get
# 需要导入模块: from myapp.ApiObject import ApiObject [as 别名]
# 或者: from myapp.ApiObject.ApiObject import write_json_core [as 别名]
def get(self):
SetUtf8.set()
if(ApiObject.check_api_capacity(self)):
return
dic=ApiFeed.get_core(self)
ApiObject.write_json_core(self,dic)