Bump to 1.3.1
[slixmpp.git] / sleekxmpp / features / feature_mechanisms / stanza / mechanisms.py
blobbbd56813adbb1001e2bacc08bb0c82b09f32f653
1 """
2 SleekXMPP: The Sleek XMPP Library
3 Copyright (C) 2011 Nathanael C. Fritz
4 This file is part of SleekXMPP.
6 See the file LICENSE for copying permission.
7 """
9 from sleekxmpp.xmlstream import ElementBase, ET
12 class Mechanisms(ElementBase):
14 """
15 """
17 name = 'mechanisms'
18 namespace = 'urn:ietf:params:xml:ns:xmpp-sasl'
19 interfaces = set(('mechanisms', 'required'))
20 plugin_attrib = name
21 is_extension = True
23 def get_required(self):
24 """
25 """
26 return True
28 def get_mechanisms(self):
29 """
30 """
31 results = []
32 mechs = self.findall('{%s}mechanism' % self.namespace)
33 if mechs:
34 for mech in mechs:
35 results.append(mech.text)
36 return results
38 def set_mechanisms(self, values):
39 """
40 """
41 self.del_mechanisms()
42 for val in values:
43 mech = ET.Element('{%s}mechanism' % self.namespace)
44 mech.text = val
45 self.append(mech)
47 def del_mechanisms(self):
48 """
49 """
50 mechs = self.findall('{%s}mechanism' % self.namespace)
51 if mechs:
52 for mech in mechs:
53 self.xml.remove(mech)