views:

156

answers:

2

I'm running the twisted.words msn protocol example from the twisted documentation located here: http://twistedmatrix.com/projects/words/documentation/examples/msn_example.py

I am aware there is another question about this sample .py on stackoverflow, but this is an entirely different problem. When I run the example, it behaves as expected. Logs into the account and displays information about users on the buddylist, but after having done that it spits out this traceback

> Traceback (most recent call last):  
> File
> "c:\python26\lib\site-packages\twisted\python\log.py",
> line 84, in callWithLogger
>     return callWithContext({"system": lp}, func, *args, **kw)   File
> "c:\python26\lib\site-packages\twisted\python\log.py",
> line 69, in callWithContext
>     return context.call({ILogContext: newCtx}, func, *args, **kw)   File
> "c:\python26\lib\site-packages\twisted\python\context.py",
> line 59, in callWithContext
>     return self.currentContext().callWithContext(ctx,
> func, *args, **kw)   File
> "c:\python26\lib\site-packages\twisted\python\context.py",
> line 37, in callWithContext
>     return func(*args,**kw)
> --- <exception caught here> ---   File "c:\python26\lib\site-packages\twisted\internet\selectreactor.py",
> line 146, in _doReadOrWrite
>     why = getattr(selectable, method)()   File
> "c:\python26\lib\site-packages\twisted\internet\tcp.py",
> line 463, in doRead
>     return self.protocol.dataReceived(data)  
> File
> "c:\python26\lib\site-packages\twisted\protocols\basic.py", line 239, indataReceived
>     return self.rawDataReceived(data)   File
> "c:\python26\lib\site-packages\twisted\words\protocols\msn.py",
> line 676 in rawDataReceived
>     self.gotMessage(m)   File "c:\python26\lib\site-packages\twisted\words\protocols\msn.py",
> line 699, in gotMessage
>     raise NotImplementedError exceptions.NotImplementedError:

could someone help me understand what that means?

A: 

The method gotMessage claims to not be implemented. That likely means that you have subclassed a class that needs gotMessage to be overridden in the subclass, but you haven't done the overriding.

Lennart Regebro
This code is a perfect copy paste from the twisted words documentation. Could this have something to do with a change in the msn protocol? Or is it more likely i'm missing a dependent library or something like that?
Ryan
It sounds like a change in the API of this part of twisted, but I'm not familiar with it so I don't know.
Lennart Regebro
A: 

It looks like it's a change to the way the MSN server operates, although it doesn't really count as a change to the protocol. What's happening is the MSN server is sending a message to the client immediately after the client connects and the Twisted words example isn't expecting that.

Assuming you're running the msn_example.py from http://twistedmatrix.com/projects/words/documentation/examples/, you can get the example working and see what's happening by adding the following code to the example (right after the end of the listSynchronized function):

def gotMessage(self, message):
    print message.headers
    print message.getMessage()

After making the changes, if you run the example, you should see the following:

...
2009-08-25 00:03:23-0700 [Notification,client] {'Content-Type': 'text/x-msmsgsinitialemailnotification; charset=UTF-8', 'MIME-Version': '1.0'}
2009-08-25 00:03:23-0700 [Notification,client] Inbox-Unread: 1
2009-08-25 00:03:23-0700 [Notification,client] Folders-Unread: 0
2009-08-25 00:03:23-0700 [Notification,client] Inbox-URL: /cgi-bin/HoTMaiL
2009-08-25 00:03:23-0700 [Notification,client] Folders-URL: /cgi-bin/folders
2009-08-25 00:03:23-0700 [Notification,client] Post-URL: http://www.hotmail.com
2009-08-25 00:03:23-0700 [Notification,client]

We can see that the server is sending the client a message which specifies the number of unread email messages there are for that account.

Hope that helps!

Cam