Philipp Hörist pushed to branch master at gajim / python-nbxmpp
Commits:
e9d06e6a by Philipp Hörist at 2017-07-29T21:33:35+02:00
Update ChangeLog
- - - - -
1 changed file:
- ChangeLog
Changes:
=====================================
ChangeLog
=====================================
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,13 +2,10 @@ python-nbxmpp 0.6.0 (tba)
* Add new getOriginID/SetOriginID method for Messages
* Add new getJid() method for Protocol
- * getTagAttr() accepts now a Namespace to filter
- * Return Protocol/Message instance when using getTag()
+ * getTagAttr() accepts now a namespace argument
+ * Add new `protocol` argument for getTag()
* Add new XEP Namespaces
- Attention:
- The API for getTag() changed in the way that it always returns a Protocol or Message instance now instead of a Node instance before. This means 'to' and 'from' attributes return now a JID instance instead of a string
-
python-nbxmpp 0.5.6 (03 June 2017)
* Support XEP-0198 Version 1.5.2
View it on GitLab: https://dev.gajim.org/gajim/python-nbxmpp/commit/e9d06e6a196105348979ed8587…
Philipp Hörist pushed to branch master at gajim / python-nbxmpp
Commits:
c3adfe67 by Philipp Hörist at 2017-07-29T21:31:09+02:00
Revert API changes
Introduce a new named argument `protocol` to return a Protocol/Message
instance when calling getTag() instead of changing the default return
value of getTag() which would be an API change.
- - - - -
1 changed file:
- nbxmpp/protocol.py
Changes:
=====================================
nbxmpp/protocol.py
=====================================
--- a/nbxmpp/protocol.py
+++ b/nbxmpp/protocol.py
@@ -957,15 +957,18 @@ class Protocol(Node):
props.append(prop)
return props
- def getTag(self, name, attrs=None, namespace=None):
+ def getTag(self, name, attrs=None, namespace=None, protocol=False):
"""
- Return at least a Protocol instance, so we dont fall back to simplexml level
+ Return the Node instance for the tag.
+ If protocol is True convert to a new Protocol/Message instance.
"""
- tag = super(Protocol, self).getTag(name, attrs, namespace)
- if not tag:
- return None
-
- return Protocol(node=tag)
+ tag = Node.getTag(self, name, attrs, namespace)
+ if protocol and tag:
+ if name == 'message':
+ return Message(node=tag)
+ else:
+ return Protocol(node=tag)
+ return tag
def __setitem__(self, item, val):
"""
@@ -1106,18 +1109,6 @@ class Message(Protocol):
attrs.append(child.getAttr('code'))
return attrs
- def getTag(self, name, attrs=None, namespace=None):
- """
- Return Message instance, fallback to Protocol
- """
- tag = super(Message, self).getTag(name, attrs, namespace)
- if not tag:
- return tag
-
- if name == 'message':
- return Message(node=tag)
- return tag
-
class Presence(Protocol):
def __init__(self, to=None, typ=None, priority=None, show=None, status=None,
View it on GitLab: https://dev.gajim.org/gajim/python-nbxmpp/commit/c3adfe67f8cf9e276ed43efa26…