Hello!
There's a problem I can't find an answer to. I'd like to design Xml based protocol. I've found XmlStream, read doc and found addObserver method. I wrote simple code:
class XmlTest(xmlstream.XmlStream): # (...) def connectionMade(self): xmlstream.XmlStream.connectionMade(self) self.addObserver("/frame", self.frameHandler) # (...)
# (...)
def frameHandler(self, data): print "Wilma, I'm Home!"
When I send XML with frame element as a root:
<frame> <whatever/> </frame>
FrameHandler isn't executed, but if I put frame element inside some other root element:
<sheep> <frame> <whatever/> </frame> </sheep>
Then my handler is activated. Why? First, I thought maybe my XPath knowledge is wrong, so I checked few tutorials[1] and they told me there's something wrong with addObserver method. How to make it working?
~MG. (Hi, I'm new here :)
Hello Marcin,
XmlStream is an implementation of XMPP/Jabber protocol (which is widely used for Instant Messaging). If you have time please read about this on www.xmpp.org. The reason why /frame handler was not executed is because XMPP/Jabber sessions starts and ends with streams like for example:
<*stream*:*stream* xmlns:*stream*="http://etherx.jabber.org/streams%22%3E . . . <message to='foo@jabber.org' from='bar@jabber.org> <body>Hello World!</body> </message> . . . </stream:stream>
You might want to take a look at twisted XML-RPC libraries.
--- Alvin
On Wed, Dec 17, 2008 at 7:25 PM, Marcin Gliński marcin@ascii-art.pl wrote:
Hello!
There's a problem I can't find an answer to. I'd like to design Xml based protocol. I've found XmlStream, read doc and found addObserver method. I wrote simple code:
class XmlTest(xmlstream.XmlStream): # (...) def connectionMade(self): xmlstream.XmlStream.connectionMade(self) self.addObserver("/frame", self.frameHandler) # (...)
# (...)
def frameHandler(self, data): print "Wilma, I'm Home!"
When I send XML with frame element as a root:
<frame> <whatever/> </frame>
FrameHandler isn't executed, but if I put frame element inside some other root element:
<sheep> <frame> <whatever/> </frame> </sheep>
Then my handler is activated. Why? First, I thought maybe my XPath knowledge is wrong, so I checked few tutorials[1] and they told me there's something wrong with addObserver method. How to make it working?
~MG. (Hi, I'm new here :)
Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
2008/12/17 Alvin Delagon:
XmlStream is an implementation of XMPP/Jabber protocol (which is widely used for Instant Messaging).
Which XmlStream? I've found two:
XMPP: twisted.words.protocols.jabber.xmlstream X-ish: twisted.words.xish.xmlstream
I've been trying to use the second one. Are they the same?
You might want to take a look at twisted XML-RPC libraries.
Sure, I will. Thanks :)
~MG.
Hello Marcin,
Marcin Gliński wrote:
2008/12/17 Alvin Delagon:
XmlStream is an implementation of XMPP/Jabber protocol (which is widely used for Instant Messaging).
Which XmlStream? I've found two:
XMPP: twisted.words.protocols.jabber.xmlstream X-ish: twisted.words.xish.xmlstream
I've been trying to use the second one. Are they the same?
use the second one, unless you are writing a Jabber client/server. The Xish one is more generic, I use it in my apps. Imagine that the XMPP session is like one giant XMPP msg/document, it's root element/node is <stream/>, a session must be opened by each party if it's bidirectional :
Client Server | <stream> | |----------------------------------------->| | | open the session | <stream> | |<-----------------------------------------| | | | <msg>.....</msg> | |----------------------------------------->| | | exchange msgs (as many as you want) | <msg>.....</msg> | |<-----------------------------------------| | | | </stream> | |----------------------------------------->| | | close the session when done | </stream> | |<-----------------------------------------| | |
I hope this helps, Gabriel
You might want to take a look at twisted XML-RPC libraries.
Sure, I will. Thanks :)
~MG.
Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Gabriel Rossetti wrote:
Hello Marcin,
Marcin Gliński wrote:
2008/12/17 Alvin Delagon:
XmlStream is an implementation of XMPP/Jabber protocol (which is widely used for Instant Messaging).
Which XmlStream? I've found two:
XMPP: twisted.words.protocols.jabber.xmlstream X-ish: twisted.words.xish.xmlstream
I've been trying to use the second one. Are they the same?
use the second one, unless you are writing a Jabber client/server. The Xish one is more generic, I use it in my apps. Imagine that the XMPP session is like one giant XMPP msg/document, it's root element/node is <stream/>, a session must be opened by each party if it's bidirectional :
Client Server | <stream> | |----------------------------------------->| | | open the session | <stream> | |<-----------------------------------------| | | | <msg>.....</msg> | |----------------------------------------->| | | exchange msgs (as many as you want) | <msg>.....</msg> | |<-----------------------------------------| | | | </stream> | |----------------------------------------->| | | close the session when done | </stream> | |<-----------------------------------------| | |
I hope this helps, Gabriel
oups, the spaces got eaten up, those pipe ('|') symbols are supposed to be aligned on the right side....
You might want to take a look at twisted XML-RPC libraries.
Sure, I will. Thanks :)
~MG.
Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python