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/c3adfe67f8cf9e276ed43efa2650b55c77ba685c
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits