def dispatchResult(self, request, node, result):
"""
Check a given result from handling a node and hand it to a process*
method which will convert the result into a node and insert it
into the DOM tree. Return the new node.
"""
if not isinstance(result, defer.Deferred):
adapter = INodeMutator(result, None)
if adapter is None:
raise NotImplementedError(
"Your factory method returned %s, but there is no "
"INodeMutator adapter registerred for %s." %
(result, getattr(result, "__class__",
None) or type(result)))
result = adapter.generate(request, node)
if isinstance(result, defer.Deferred):
self.outstandingCallbacks += 1
result.addCallback(self.dispatchResultCallback, request, node)
result.addErrback(self.renderFailure, request)
# Got to wait until the callback comes in
return result
评论列表
文章目录