comparison idavoll/xmpp_error.py @ 1:4cc41776b7d7

Initial revision
author Ralph Meijer <ralphm@ik.nu>
date Wed, 23 Jun 2004 14:31:49 +0000
parents
children 32e1561cd68e
comparison
equal deleted inserted replaced
0:1b68bdae21eb 1:4cc41776b7d7
1 conditions = {
2 'not-authorized': {'code': '401', 'type': 'cancel'},
3 'item-not-found': {'code': '404', 'type': 'cancel'},
4 'feature-not-implemented': {'code': '501', 'type': 'cancel'},
5 }
6
7 def error_from_iq(iq, condition, text = '', type = None):
8 iq.swapAttributeValues("to", "from")
9 iq["type"] = 'error'
10 e = iq.addElement("error")
11
12 c = e.addElement(condition)
13 c["xmlns"] = "urn:ietf:params:xml:ns:xmpp-stanzas"
14
15 if type == None:
16 type = conditions[condition]['type']
17
18 code = conditions[condition]['code']
19
20 e["code"] = code
21 e["type"] = type
22
23 if text:
24 t = e.addElement("text", None, text)
25 t["xmlns"] = "urn:ietf:params:xml:ns:xmpp-stanzas"
26
27 return iq