diff options
author | Lance Stout <lancestout@gmail.com> | 2012-10-22 20:10:07 -0700 |
---|---|---|
committer | Lance Stout <lancestout@gmail.com> | 2012-10-22 20:10:07 -0700 |
commit | 3655827ef2e268e9ab327e4a6c788c3e336146e0 (patch) | |
tree | 06a916dbfb9ce40897fd56a2051bbeeea64d6e17 | |
parent | 12e0e1a16b56f8a4797912ae0ab4c057c07b0b9f (diff) | |
parent | c5046b9c91a77488424c1f77407a2875a9fea45a (diff) | |
download | slixmpp-3655827ef2e268e9ab327e4a6c788c3e336146e0.tar.gz slixmpp-3655827ef2e268e9ab327e4a6c788c3e336146e0.tar.bz2 slixmpp-3655827ef2e268e9ab327e4a6c788c3e336146e0.tar.xz slixmpp-3655827ef2e268e9ab327e4a6c788c3e336146e0.zip |
Merge branch 'master' into develop
-rw-r--r-- | sleekxmpp/jid.py | 51 | ||||
-rw-r--r-- | sleekxmpp/roster/item.py | 4 |
2 files changed, 27 insertions, 28 deletions
diff --git a/sleekxmpp/jid.py b/sleekxmpp/jid.py index 007bebac..eac51dad 100644 --- a/sleekxmpp/jid.py +++ b/sleekxmpp/jid.py @@ -421,33 +421,32 @@ class JID(object): if jid is None or jid == '': jid = '' - if jid in JID_CACHE: - self._jid = JID_CACHE[jid] + if not jid: + jid = (None, None, None) + elif jid in JID_CACHE: + jid = JID_CACHE[jid] + elif not isinstance(jid, JID): + jid = _parse_jid(jid) else: - if not jid: - jid = (None, None, None) - elif not isinstance(jid, JID): - jid = _parse_jid(jid) - else: - jid = jid._jid - - local, domain, resource = jid - - local = kwargs.get('local', local) - domain = kwargs.get('domain', domain) - resource = kwargs.get('resource', resource) - - if 'local' in kwargs: - local = _escape_node(local) - if 'domain' in kwargs: - domain = _validate_domain(domain) - if 'resource' in kwargs: - resource = _validate_resource(resource) - - self._jid = (local, domain, resource) - JID_CACHE[_format_jid(*self._jid)] = self._jid - if len(JID_CACHE) > JID_CACHE_MAX_SIZE: - JID_CACHE.popitem(False) + jid = jid._jid + + local, domain, resource = jid + + local = kwargs.get('local', local) + domain = kwargs.get('domain', domain) + resource = kwargs.get('resource', resource) + + if 'local' in kwargs: + local = _escape_node(local) + if 'domain' in kwargs: + domain = _validate_domain(domain) + if 'resource' in kwargs: + resource = _validate_resource(resource) + + self._jid = (local, domain, resource) + JID_CACHE[_format_jid(*self._jid)] = self._jid + if len(JID_CACHE) > JID_CACHE_MAX_SIZE: + JID_CACHE.popitem(False) def unescape(self): """Return an unescaped JID object. diff --git a/sleekxmpp/roster/item.py b/sleekxmpp/roster/item.py index 6e9c0d01..ae194e0a 100644 --- a/sleekxmpp/roster/item.py +++ b/sleekxmpp/roster/item.py @@ -479,11 +479,11 @@ class RosterItem(object): self.xmpp.event('roster_subscription_removed', presence) def handle_probe(self, presence): - if self['to']: + if self['from']: self.send_last_presence() if self['pending_out']: self.subscribe() - if not self['to']: + if not self['from']: self._unsubscribed() def reset(self): |