def lookupFunction(self, name):
"""
Return a callable to invoke when executing the named command.
@param name: the normalized name (from the wire) of the command.
@return: a function that takes one argument (a Box) and returns a box,
for handling the command identified by the given name.
"""
# Try to find a high-level method to invoke, and if we can't find one,
# fall back to a low-level one.
cd = self._commandDispatch
if name in cd:
commandClass, responderFunc = cd[name]
responderMethod = types.MethodType(responderFunc, self, self.__class__)
return self._wrapWithSerialization(responderMethod, commandClass)
# Fall back to simplistic command dispatching - this uses only strings,
# not encoded/decoded values.
fName = self.baseDispatchPrefix + (name.upper())
return getattr(self, fName, None)
评论列表
文章目录