XPath in XmlStream.addObserver doesn't work as it should
What I want to do is only react to certain root elements. For example, if a user submits an XmlStream that looks like this:
<auth>
<login>user</login>
<pass>dupa.8</pass>
</auth>
My ._auth method should be executed. I did it using the addObserver method, which is called inside the connectionMade method.
self.addObserver("/auth", self._auth)
AFAIK XPath - if I write "/ auth" it means I want my root element to be "auth", so the message is:
<longtagislong>
<auth>...</auth>
</longtagislong>
... should be rejected as auth is not root.
But Twisted, however, doesn't work the way I thought it should - my _auth method is executed when the second message appears (with the auth element inside the tree), not the first one with the auth element as root.
So my question is, how do I tell the Twisted and addObserver method that I only want to react if the root element name is "auth"?
+1
source to share