Changeset 53:4aec395fda5b for wokkel/compat.py
- Timestamp:
- Apr 7, 2009, 12:13:08 PM (13 years ago)
- Branch:
- default
- Convert:
- svn:b33ecbfc-034c-dc11-8662-000475d9059e/trunk@165
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
wokkel/compat.py
r44 r53 7 7 from twisted.words.protocols.jabber import xmlstream 8 8 from twisted.words.xish import domish 9 10 def toResponse(stanza, stanzaType=None):11 """12 Create a response stanza from another stanza.13 14 This takes the addressing and id attributes from a stanza to create a (new,15 empty) response stanza. The addressing attributes are swapped and the id16 copied. Optionally, the stanza type of the response can be specified.17 18 @param stanza: the original stanza19 @type stanza: L{domish.Element}20 @param stanzaType: optional response stanza type21 @type stanzaType: C{str}22 @return: the response stanza.23 @rtype: L{domish.Element}24 """25 26 toAddr = stanza.getAttribute('from')27 fromAddr = stanza.getAttribute('to')28 stanzaID = stanza.getAttribute('id')29 30 response = domish.Element((None, stanza.name))31 if toAddr:32 response['to'] = toAddr33 if fromAddr:34 response['from'] = fromAddr35 if stanzaID:36 response['id'] = stanzaID37 if stanzaType:38 response['type'] = stanzaType39 40 return response41 42 43 9 44 10 class BootstrapMixin(object):
Note: See TracChangeset
for help on using the changeset viewer.