summaryrefslogtreecommitdiff
path: root/sleekxmpp/jid.py
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2012-10-22 20:09:35 -0700
committerLance Stout <lancestout@gmail.com>2012-10-22 20:09:35 -0700
commitc5046b9c91a77488424c1f77407a2875a9fea45a (patch)
tree5fda09e6a04cbb271142c93f03100bdee9e373a6 /sleekxmpp/jid.py
parent4598031dd2493a85824d5d9f7488703f5d2d0a14 (diff)
downloadslixmpp-c5046b9c91a77488424c1f77407a2875a9fea45a.tar.gz
slixmpp-c5046b9c91a77488424c1f77407a2875a9fea45a.tar.bz2
slixmpp-c5046b9c91a77488424c1f77407a2875a9fea45a.tar.xz
slixmpp-c5046b9c91a77488424c1f77407a2875a9fea45a.zip
Fix JID cache (wrong in-progress version comitted earlier)
Diffstat (limited to 'sleekxmpp/jid.py')
-rw-r--r--sleekxmpp/jid.py51
1 files changed, 25 insertions, 26 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.