当前位置: 首页>>代码示例>>Python>>正文


Python ApiObject.ApiObject类代码示例

本文整理汇总了Python中myapp.ApiObject.ApiObject的典型用法代码示例。如果您正苦于以下问题:Python ApiObject类的具体用法?Python ApiObject怎么用?Python ApiObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ApiObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get

	def get(self):
		#日本語対応
		SetUtf8.set()
		if(ApiObject.check_api_capacity(self)):
			return
		dic=ApiBookmark.get_core(self)
		ApiObject.write_json_core(self,dic)
开发者ID:abars,项目名称:illustbook,代码行数:7,代码来源:ApiBookmark.py

示例2: mapping

	def mapping(bbs,thread_key):
		#直値
		if(len(thread_key)>20):
			return ApiObject.get_cached_object(thread_key)
		
		#キャッシュヒット判定
		bbs_key=str(bbs.key())
		mapped_key=memcache.get(BbsConst.OBJECT_THREAD_ID_MAPPING_HEADER+"_"+bbs_key+"_"+thread_key)
		if mapped_key is not None:
			return ApiObject.get_cached_object(mapped_key)
		
		#探索
		query=db.Query(MesThread,keys_only=True)
		query.filter("bbs_key =",bbs)
		query.filter("short =",thread_key)
		thread=None
		try:
			thread=query[0]
			thread=ApiObject.get_cached_object(thread)
		except:
			thread=None

		#キャッシュに登録
		if thread and thread.short:
			new_key=str(thread.key())
			memcache.set(BbsConst.OBJECT_THREAD_ID_MAPPING_HEADER+"_"+bbs_key+"_"+thread.short,new_key,BbsConst.OBJECT_MAPPING_CACHE_TIME)
		
		#image_keyを取得しておく
		if thread and thread.image_key:
			thread.cached_image_key=str(thread.image_key.key())

		#スレッドを返す
		return thread
开发者ID:abars,项目名称:illustbook,代码行数:33,代码来源:MappingThreadId.py

示例3: post

	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")
开发者ID:,项目名称:,代码行数:29,代码来源:

示例4: user_get_profile

	def user_get_profile(req,user_id,bookmark=None):
		if(not bookmark):
			bookmark=ApiObject.get_bookmark_of_user_id(user_id)
		if(not bookmark):
			return []
		one_dic=ApiObject.create_user_object(req,bookmark)
		one_dic["profile"]=bookmark.profile
		return one_dic
开发者ID:abars,项目名称:illustbook,代码行数:8,代码来源:ApiUser.py

示例5: bookmark_get_app_list

	def bookmark_get_app_list(req,user_id):
		bookmark=ApiObject.get_bookmark_of_user_id(user_id)
		if(bookmark==None):
			return []
		dic=[]
		for app_key in bookmark.app_key_list:
			app=db.get(app_key)
			one_dic=ApiObject.create_app_object(req,app)
			dic.append(one_dic)
		return dic
开发者ID:abars,项目名称:illustbook,代码行数:10,代码来源:ApiBookmark.py

示例6: user_get_home_timeline

	def user_get_home_timeline(req,user_id):
		#そのユーザのフォローしているユーザのタイムライン

		bookmark=ApiObject.get_bookmark_of_user_id(user_id)
		if(bookmark==None):
			return []
		feed_key_list=ApiObject.offset_and_limit(req,bookmark.stack_feed_list)
		feed_list=ApiObject.get_cached_object_list(feed_key_list)
		dic=ApiObject.create_feed_object_list(req,feed_list,feed_key_list)
		return dic
开发者ID:abars,项目名称:illustbook,代码行数:10,代码来源:ApiUser.py

示例7: post_snapshot

	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"})
开发者ID:,项目名称:,代码行数:11,代码来源:

示例8: bookmark_get_thread_list

	def bookmark_get_thread_list(req,user_id,bookmark=None):
		if(not bookmark):
			bookmark=ApiObject.get_bookmark_of_user_id(user_id)
		if(bookmark==None):
			return []

		thread_key_list=bookmark.thread_key_list
		thread_key_list=ApiObject.offset_and_limit(req,thread_key_list)

		dic=ApiObject.create_thread_object_list(req,thread_key_list,"bookmark")
		ApiBookmark.add_removed_thread_to_dic(req,dic,thread_key_list)

		return dic
开发者ID:abars,项目名称:illustbook,代码行数:13,代码来源:ApiBookmark.py

示例9: user_get_bbs_list

	def user_get_bbs_list(req,user_id):
		query=db.Query(Bbs,keys_only=True)
		query=query.filter("user_id =",user_id).order("-create_date")
		bbs_key_list=query.fetch(limit=1000,offset=0)
		dic=[]
		bbs_list=ApiObject.get_cached_object_list(bbs_key_list)
		for bbs in bbs_list:
			if(bbs.del_flag):
				continue
			one_dic=ApiObject.create_bbs_object(req,bbs)
			if(not one_dic):
				continue
			dic.append(one_dic)
		return dic;
开发者ID:abars,项目名称:illustbook,代码行数:14,代码来源:ApiUser.py

示例10: post_command

	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"})
开发者ID:,项目名称:,代码行数:31,代码来源:

示例11: render_comment_list

    def render_comment_list(req, all_threads_cached, host_url, bbs,
                            show_comment_form, logined, is_admin, user_name,
                            user):
        edit_flag = False
        show_ip = False

        bbs_key = bbs.key()

        #コメントとレスを先行して全て取得
        entry_key_list = []
        for thread in all_threads_cached:
            if not thread:
                continue
            for entry in thread.cached_entry_key:
                entry_key_list.append(entry)
        entry_hash = ApiObject.get_cached_object_hash(entry_key_list)
        res_hash = ShowEntry._get_entry_res(entry_hash)

        #コメントをレンダリング
        for thread in all_threads_cached:
            if not thread:
                continue
            entry_list = []
            for entry in thread.cached_entry_key:
                one_entry = entry_hash[entry]
                entry_list.append(one_entry)
            thread.cached_render_comment = ShowEntry._render_comment_core(
                req, host_url, bbs, thread, entry_list, edit_flag, bbs_key,
                logined, show_comment_form, is_admin, user_name, user,
                res_hash, show_ip)
开发者ID:abars,项目名称:illustbook,代码行数:30,代码来源:ShowEntry.py

示例12: get_core

	def get_core(self):
		#パラメータ取得
		method=""
		if(self.request.get("method")):
			method=self.request.get("method");
		
		user_id=""
		if(self.request.get("user_id")):
			user_id=self.request.get("user_id")
		
		#返り値
		dic={"method":method}

		#ユーザクラス
		if(method=="getUser"):
			dic=ApiUser.user_get_user(self,user_id)
		if(method=="getProfile"):
			dic=ApiUser.user_get_profile(self,user_id)
		if(method=="getFollow" or method=="getFollowFast"):
			dic=ApiUser.user_get_follow(self,user_id,method=="getFollowFast")
		if(method=="getFollower" or method=="getFollowerFast"):
			dic=ApiUser.user_get_follower(self,user_id,method=="getFollowerFast")
		if(method=="getBbsList"):
			dic=ApiUser.user_get_bbs_list(self,user_id)
		if(method=="getThreadList"):
			dic=ApiUser.user_get_thread_list(self,user_id)
		if(method=="getTimeline"):
			dic=ApiUser.user_get_timeline(self,user_id)
		if(method=="getHomeTimeline"):
			dic=ApiUser.user_get_home_timeline(self,user_id)
			
		return ApiObject.add_json_success_header(dic)
开发者ID:abars,项目名称:illustbook,代码行数:32,代码来源:ApiUser.py

示例13: get_core

	def get_core(self):
		#パラメータ取得
		method=""
		if(self.request.get("method")):
			method=self.request.get("method");
		
		user_id=""
		if(self.request.get("user_id")):
			user_id=self.request.get("user_id")
		
		#返り値
		dic={"method":method}

		#ブックマーククラス
		if(method=="getThreadList"):
			dic=ApiBookmark.bookmark_get_thread_list(self,user_id)
		if(method=="getBbsList"):
			dic=ApiBookmark.bookmark_get_bbs_list(self,user_id)
		if(method=="getAppList"):
			dic=ApiBookmark.bookmark_get_app_list(self,user_id)
		if(method=="getBbsUserList"):
			dic=ApiBookmark.bookmark_get_bbs_user_list(self)
		if(method=="getThreadUserList"):
			dic=ApiBookmark.bookmark_get_thread_user_list(self)
		if(method=="getAppUserList"):
			dic=ApiBookmark.bookmark_get_app_user_list(self)
		
		if(dic==None):
			dic={"status":"failed","message":"ブックマークの取得に失敗しました。"}
		else:
			dic=ApiObject.add_json_success_header(dic)
		
		return dic
开发者ID:abars,项目名称:illustbook,代码行数:33,代码来源:ApiBookmark.py

示例14: _append_list_core

	def _append_list_core(data,bookmark_key_list):
		#batch get
		try:
			bookmark_list=db.get(bookmark_key_list)
		except db.BadValueError as e:
			logging.error(e)
			bookmark_list=None

		#BadValueError: Property follower_list is requiredの対策
		if(bookmark_list==None):
			bookmark_list=[]
			for bookmark_key in bookmark_key_list:
				try:
					bookmark_list.append(db.get(bookmark_key))
				except db.BadValueError as e:
					logging.error(e)

		#update and put
		put_bookmark_list=[]
		for bookmark in bookmark_list:
			if(bookmark):
				bookmark=ApiObject.set_list_if_empty(bookmark)
				if(StackFeed._append_one_core(data,bookmark)):
					put_bookmark_list.append(bookmark)
		
		#batch put
		if(len(put_bookmark_list)>=1):
			db.put(put_bookmark_list)
			put_bookmark_list=[]
开发者ID:abars,项目名称:illustbook,代码行数:29,代码来源:StackFeed.py

示例15: _get_related

	def _get_related(bbs,thread,is_iphone,is_tablet):
		related_illust_cnt=6

		try:
			thread_query=ShowThread._get_related_query(bbs,thread)
			thread_query.filter('create_date > ',thread.create_date)
			thread_query.order('create_date')
			thread_after=thread_query.fetch(limit=related_illust_cnt)
		except:
			thread_after=[]

		try:
			thread_query=ShowThread._get_related_query(bbs,thread)
			thread_query.filter('create_date < ',thread.create_date)
			thread_query.order('-create_date')
			thread_before=thread_query.fetch(limit=related_illust_cnt*2-len(thread_after))
		except:
			thread_before=[]

		all_threads=[]
		if(thread_after):
			thread_after.reverse()

		for after in thread_after:
			all_threads.append(after)
		for before in thread_before:
			all_threads.append(before)

		if(not is_iphone and not is_tablet):
			while(len(all_threads)>related_illust_cnt+1):
				no=int(random.random()*len(all_threads))
				all_threads.remove(all_threads[no])

		all_threads_cached=ApiObject.get_cached_object_list(all_threads)
		return all_threads_cached
开发者ID:abars,项目名称:illustbook,代码行数:35,代码来源:ShowThread.py


注:本文中的myapp.ApiObject.ApiObject类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。