annotate idavoll/xmpp_error.py @ 46:979e53b54267

Redefined several classes as subclasses of the implementations in backend.py. Removed PersistenceService.
author Ralph Meijer <ralphm@ik.nu>
date Wed, 03 Nov 2004 14:06:08 +0000
parents 53b1bea9289b
children 5191ba7c4df8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
76efc9114469 Code cleanup
Ralph Meijer <ralphm@ik.nu>
parents: 3
diff changeset
1 NS_XMPP_STANZAS = "urn:ietf:params:xml:ns:xmpp-stanzas"
76efc9114469 Code cleanup
Ralph Meijer <ralphm@ik.nu>
parents: 3
diff changeset
2
1
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
3 conditions = {
3
32e1561cd68e Added bad-request error.
Ralph Meijer <ralphm@ik.nu>
parents: 1
diff changeset
4 'bad-request': {'code': '400', 'type': 'modify'},
1
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
5 'not-authorized': {'code': '401', 'type': 'cancel'},
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
6 'item-not-found': {'code': '404', 'type': 'cancel'},
19
53b1bea9289b Added two errors
Ralph Meijer <ralphm@ik.nu>
parents: 13
diff changeset
7 'not-acceptable': {'code': '406', 'type': 'modify'},
53b1bea9289b Added two errors
Ralph Meijer <ralphm@ik.nu>
parents: 13
diff changeset
8 'conflict': {'code': '409', 'type': 'cancel'},
13
226a97dd79ff Added two errors
Ralph Meijer <ralphm@ik.nu>
parents: 6
diff changeset
9 'internal-server-error': {'code': '500', 'type': 'wait'},
1
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
10 'feature-not-implemented': {'code': '501', 'type': 'cancel'},
13
226a97dd79ff Added two errors
Ralph Meijer <ralphm@ik.nu>
parents: 6
diff changeset
11 'service-unavailable': {'code': '503', 'type': 'cancel'},
1
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
12 }
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
13
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
14 def error_from_iq(iq, condition, text = '', type = None):
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
15 iq.swapAttributeValues("to", "from")
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
16 iq["type"] = 'error'
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
17 e = iq.addElement("error")
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
18
6
76efc9114469 Code cleanup
Ralph Meijer <ralphm@ik.nu>
parents: 3
diff changeset
19 c = e.addElement((NS_XMPP_STANZAS, condition), NS_XMPP_STANZAS)
1
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
20
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
21 if type == None:
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
22 type = conditions[condition]['type']
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
23
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
24 code = conditions[condition]['code']
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
25
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
26 e["code"] = code
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
27 e["type"] = type
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
28
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
29 if text:
6
76efc9114469 Code cleanup
Ralph Meijer <ralphm@ik.nu>
parents: 3
diff changeset
30 t = e.addElement((NS_XMPP_STANZAS, "text"), NS_XMPP_STANZAS, text)
1
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
31
4cc41776b7d7 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
32 return iq