Mercurial > libervia-pubsub
comparison idavoll/xmpp_error.py @ 6:76efc9114469
Code cleanup
author | Ralph Meijer <ralphm@ik.nu> |
---|---|
date | Sun, 27 Jun 2004 15:07:11 +0000 |
parents | 32e1561cd68e |
children | 226a97dd79ff |
comparison
equal
deleted
inserted
replaced
5:05a5d412e1b1 | 6:76efc9114469 |
---|---|
1 NS_XMPP_STANZAS = "urn:ietf:params:xml:ns:xmpp-stanzas" | |
2 | |
1 conditions = { | 3 conditions = { |
2 'bad-request': {'code': '400', 'type': 'modify'}, | 4 'bad-request': {'code': '400', 'type': 'modify'}, |
3 'not-authorized': {'code': '401', 'type': 'cancel'}, | 5 'not-authorized': {'code': '401', 'type': 'cancel'}, |
4 'item-not-found': {'code': '404', 'type': 'cancel'}, | 6 'item-not-found': {'code': '404', 'type': 'cancel'}, |
5 'feature-not-implemented': {'code': '501', 'type': 'cancel'}, | 7 'feature-not-implemented': {'code': '501', 'type': 'cancel'}, |
8 def error_from_iq(iq, condition, text = '', type = None): | 10 def error_from_iq(iq, condition, text = '', type = None): |
9 iq.swapAttributeValues("to", "from") | 11 iq.swapAttributeValues("to", "from") |
10 iq["type"] = 'error' | 12 iq["type"] = 'error' |
11 e = iq.addElement("error") | 13 e = iq.addElement("error") |
12 | 14 |
13 c = e.addElement(condition) | 15 c = e.addElement((NS_XMPP_STANZAS, condition), NS_XMPP_STANZAS) |
14 c["xmlns"] = "urn:ietf:params:xml:ns:xmpp-stanzas" | |
15 | 16 |
16 if type == None: | 17 if type == None: |
17 type = conditions[condition]['type'] | 18 type = conditions[condition]['type'] |
18 | 19 |
19 code = conditions[condition]['code'] | 20 code = conditions[condition]['code'] |
20 | 21 |
21 e["code"] = code | 22 e["code"] = code |
22 e["type"] = type | 23 e["type"] = type |
23 | 24 |
24 if text: | 25 if text: |
25 t = e.addElement("text", None, text) | 26 t = e.addElement((NS_XMPP_STANZAS, "text"), NS_XMPP_STANZAS, text) |
26 t["xmlns"] = "urn:ietf:params:xml:ns:xmpp-stanzas" | |
27 | 27 |
28 return iq | 28 return iq |