Ignore:
Timestamp:
Apr 7, 2009, 12:13:08 PM (11 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
Convert:
svn:b33ecbfc-034c-dc11-8662-000475d9059e/trunk@165
Message:

Release Wokkel 0.5.0.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wokkel/compat.py

    r44 r53  
    77from twisted.words.protocols.jabber import xmlstream
    88from 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 id
    16     copied. Optionally, the stanza type of the response can be specified.
    17 
    18     @param stanza: the original stanza
    19     @type stanza: L{domish.Element}
    20     @param stanzaType: optional response stanza type
    21     @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'] = toAddr
    33     if fromAddr:
    34         response['from'] = fromAddr
    35     if stanzaID:
    36         response['id'] = stanzaID
    37     if stanzaType:
    38         response['type'] = stanzaType
    39 
    40     return response
    41 
    42 
    439
    4410class BootstrapMixin(object):
Note: See TracChangeset for help on using the changeset viewer.