fritzy / SleekXMPP

Python 2.6+/3.1+ XMPP Library
http://groups.google.com/group/sleekxmpp-discussion
Other
1.1k stars 299 forks source link

Stanza default namespace #229

Closed P-Product closed 11 years ago

P-Product commented 11 years ago

Hi guys!

I am writing an internal xmpp openfire bot with a great errbot library.

However I needed some additional xmpp features specifically I had to work directly with a roster

My version of sleekxmpp is (1.1.11)

Today I have killed 4 hour on trying to understand why the built in roster did not update it's RosterItem resources although the info was in the stanzas

and i found out why: Openfire does not set the namespace of presence stanzas to 'jabber:client'. And ElementBase just doesn't see those subelements!

<presence id='WbcV9-58' from="leonid@server/Spark 2.6.3" to="leonid@server/aWer4s">
    <status>Away</status>
    <priority>1</priority>
    <show>away</show>
</presence>

I would love to see an option for sleekxmpp that would set the jabber:client as the default namespace

what would you suggest?

legastero commented 11 years ago

Unless OpenFire or Spark is explicitly sending xmlns="", then it should already be inheriting the stream's jabber:client default namespace.

legastero commented 11 years ago

If you use Python 2.x, you can add a print or log call in sleekxmpp/xmlstream/filesocket.py in FileSocket.read to print the raw incoming data before it goes through the XML parser to see if 'xmlns=""` is being sent.

P-Product commented 11 years ago

no, it doesnt have this attribute

P-Product commented 11 years ago

I am using Python3.3

P-Product commented 11 years ago

I have also used pigin's XMPP console to see the raw stanzas. The one I pasted above is copied from there.

P-Product commented 11 years ago

How come it will be using the default namespace? the xml.etree.ET.iterparse will just take whatever is in the xml, and all access methods in ElementBase are using the '{ns}tag' notation. Even when used with the '|*' for all languages it tries to get values with the XML_NS = 'http://www.w3.org/XML/1998/namespace' ;(

P-Product commented 11 years ago

OK, I think we can close this issue My bad, Openfire was sending the correct namespace. I was using one of it's ad-hoc commands to get ActiveUserPresence and then it returned an xml where the presences were actually values of jabber:x:data form and did not have the jabber:client xmlns set. So when I was creating Presence from the xml it wouldn't work. But I have also missed the expected fields in the standard client_roster. And I thought that these two had the same source but it turned out that the client_roster was not properly updated because i didn't do 'send_presence' at the very start.