FeedMesh Python Solution
Comments Off Ralph Meijer’s blog has a nice entry about connecting to the FeedMesh network, even with sample code.
This solution was exactly what I was looking for. The Twisted Framework is used for handling both the network connection and the XML streaming (Xish package).
However, I ran into a little problem when testing the code out. I found was that the XmlStreamFactory failed to instantiate. It required another parameter in its constructor. WTF?
Simple reason. Ralph has been making changes to remove all the Jabber specific stuff out of Xish. That parameter was for Jabber and Ralph’s changes haven’t made it out into a new release.
So, for those that already have Xish 0.1.0 installed, here are the following code changes:
auth = xmlstream.Authenticator('')
f = xmlstream.XmlStreamFactory(auth)
Original Sample Code:
from twisted.xish import xmlstream
from twisted.internet import reactor
def onPing(element):
print 'Ping for %s' % (element['rss'])
def connected(xs):
print 'Connected!'
xs.addObserver('/weblog', onPing)
f = xmlstream.XmlStreamFactory()
f.addBootstrap(xmlstream.STREAM_START_EVENT, connected)
reactor.connectTCP('sandbox.pubsub.com', 9999, f)
reactor.run()
[Edited: Changed the code tag to a pre tag (Of the code samples) because those sections weren't rendering nicely.]
No Comments
No comments yet.
RSS feed for comments on this post.
Sorry, the comment form is closed at this time.