コード例 #1
0
ファイル: mydatabase.py プロジェクト: mengalong/public-soft
	def do_get_meta_attr(self):
		ret_obj = {
			"return_value" : 1,
			"return_desc" : "get-meta-attr failed"
		}
		query = {"_id":self.para.id}

		if self.is_exists(query) == 1:
			loginfo = "Cannot find the record which query is:" + bytes(query)
			print logfinfo
			self.log.info(loginfo)
			return ret_obj

		meta_string = self.db_collection.find_one(query)
		tmp_obj = meta_string
		#need to check if the key is exists
		for key in self.para.key.split("."):
			if common.is_key_in_dict(key, tmp_obj) != 0:
				loginfo = "the key:\"%s\" doesnot exists!" % (self.para.key)
				print loginfo
				self.log.info(loginfo)
				return ret_obj
			else:
				tmp_obj = tmp_obj[key]

		if type(tmp_obj) != dict:
			print tmp_obj
		else:
			if self.para.pretty == True:
				common.json_print_pretty(tmp_obj)
			else:
				common.json_print_string(tmp_obj)
		return ret_obj
コード例 #2
0
ファイル: mydatabase.py プロジェクト: mengalong/public-soft
	def do_get_meta_all(self):
		ret_obj = {
			"return_value" : 1,
			"return_desc" : "get-meta-all failed"
		}
		data = {"_id":self.para.id}
		if self.is_exists(data) == 1:
			loginfo = "Cannot find the record which id="+bytes(self.para.id)
			print loginfo
			self.log.info(loginfo)
			return ret_obj
		meta_string = self.db_collection.find_one(data)
		if self.para.pretty == True:
			common.json_print_pretty(meta_string)
		else:
			common.json_print_string(meta_string)

		ret_obj["return_value"] = 0
		ret_obj["return_desc"] = "get-meta-all success"
		return ret_obj