2

I'm subclassing WampCraServerProtocol (from Autobahn Python) and overriding getAuthSecret. I understand that now I can return a deferred from that method, however, when doing a simple test:

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

... I get the following error on my WampCraClientProtocol:

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

Ok, that alone is confusing already. Are there special requirements over the deferred that getAuthSecret returns?

Ok, moving on, based on that error, I added a (trivial) len method to the deferred I'm returning:

def getAuthSecret(self, authKey):
    #secret_deferred = self.factory.get_secret(authKey)
    deferred = Deferred()
    deferred.__len__ = lambda: 1
    deferred.callback("secret")
    return deferred

... in that case, I get:

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

That confuses me even more. I just want to know the correct way to return a deferred from that method. (I should note that everything works perfectly if a return a plain simple string). Thanks.

Emile Cormier
  • 28,391
  • 15
  • 94
  • 122
sroj
  • 254
  • 2
  • 10

1 Answers1

1

This works for me:

https://github.com/tavendo/AutobahnPython/blob/master/examples/wamp/authentication/server.py#L72

What AutobahnPython version are you using?

Update:

v0.5.9 has a bug regarding deferred based authentication (see comments below). It was fixed on v0.5.14. Wamp Cra deferred based authentication works fine on that version.

ismail
  • 46,010
  • 9
  • 86
  • 95
oberstet
  • 21,353
  • 10
  • 64
  • 97
  • That should work for me, too. It's quite similar to my code. As per pip freeze, I'm using version 0.5.9. – sroj Feb 24 '13 at 18:35
  • 1
    I guess the issue you see was fixed after 0.5.9 (in commit https://github.com/tavendo/AutobahnPython/commit/3b2cd64d2489c4924095c6e406b2676a85967be8). I'd recommend to use the master or maintenance_v0_5 branch on GitHub, since there wasn't a release after 0.5.9 yet that was published on PyPi. – oberstet Feb 25 '13 at 07:25
  • Solved! Indeed, v0.5.9 is broken in that regard. Everything worked fine after I checked out the Master branch. Thanks! I spent almost 4 hours hitting my head against the screen on friday. I suggest publishing the latest release to PyPi asap, though. – sroj Feb 25 '13 at 11:53
  • Sorry for the inconvenience;( We've now published 0.5.14 to PyPi. – oberstet Feb 25 '13 at 13:01
  • No problem :) Excellent piece of software, Autobahn, by the way. – sroj Feb 25 '13 at 13:44