在使用Autobahn Wamp Cra时,如何使用延迟返回身份验证密码?

2024-10-03 11:15:05 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在子类化WampCraServerProtocol(来自autobahnpython)并重写{}。我知道现在我可以从该方法返回一个deferred,但是,在进行一个简单的测试时:

def getAuthSecret(self, authKey):        
    deferred = Deferred()
    deferred.callback("secret")
    return deferred

。。。我的WampCraClientProtocol上出现以下错误:

Authentication Error! http://api.wamp.ws/error#generic Deferred instance has no attribute '__len__' None

好吧,光是这一点就已经令人困惑了。对getAuthSecret返回的延迟是否有特殊要求?在

好的,继续,基于这个错误,我在返回的deferred中添加了一个(普通的)len方法:

^{pr2}$

。。。在这种情况下,我得到:

Authentication Error! http://api.wamp.ws/error#generic unsupported operand type(s) for +: 'instance' and 'str' None

这让我更加困惑。 我只想知道从该方法返回延迟的正确方法。 (我应该注意,如果返回一个简单的字符串,那么一切都会完美地工作)。 谢谢。在


Tags: 方法instanceapihttpauthenticationlenws错误