一、 查询数据库
def initEmailToAvatar(self, avatarId):
self.queryEmailsFromDataBase(avatarId, self.initEmailToAvatarCB)KBEngine.executeRawDatabaseCommand(sql, callback_inner)
二 特殊字典
# -*- coding: utf-8 -*-
#
from KBEDebug import *
class HeroDictConverter:
"""
"""
def getDictFromObj( self, obj ):
"""
The method converts a wrapper instance to a FIXED_DICT instance.
@param obj: The obj parameter is a wrapper instance.
@return: This method should return a dictionary(or dictionary-like object) that contains the same set of keys as a FIXED_DICT instance.
"""
DEBUG_MSG("HeroDictConverter::getDictFromObj:%s" % obj)
if obj is None:
return { "heros" : [] }
return {"heros": list(obj.values())}
def createObjFromDict( self, dictData ):
"""
This method converts a FIXED_DICT instance to a wrapper instance.
@param dictData: The dictData parameter is a FIXED_DICT instance.
@return: The method should return the wrapper instance constructed from the information in dict.
"""
DEBUG_MSG( "HeroDictConverter::createObjFromDict:%s" % dictData.items() )
obj = {}
if len(dictData) > 0:
for data in dictData["heros"]:
obj[data["dbid"]] = data
return obj
def isSameType( self, obj ):
"""
This method check whether an object is of the wrapper type.
@param obj: The obj parameter in an arbitrary Python object.
@return: This method should return true if obj is a wrapper instance.
"""
if obj is None: return True
return isinstance( obj, dict )
inst = HeroDictConverter()
三、 在配置文件中定于存储了,不能在init中使用 dicts = {} 不然会将数据清空了,直接不写这个,默认也是会初始化好