]> git.llucax.com Git - software/pymin.git/blob - services/dns/mx.py
Add an example of regular attributes usage with a ValidatedClass
[software/pymin.git] / services / dns / mx.py
1 # vim: set encoding=utf-8 et sw=4 sts=4 :
2
3 # TODO documentation, validation
4
5 from pymin.seqtools import Sequence
6 from pymin.service.util import DictComposedSubHandler
7
8 __all__ = ('MailExchangeHandler',)
9
10
11 class MailExchange(Sequence):
12     def __init__(self, mx, prio):
13         self.mx = mx
14         self.prio = prio
15     def update(self, prio=None):
16         if prio is not None: self.prio = prio
17     def as_tuple(self):
18         return (self.mx, self.prio)
19
20 class MailExchangeHandler(DictComposedSubHandler):
21     handler_help = u"Manage DNS mail exchangers (MX)"
22     _comp_subhandler_cont = 'zones'
23     _comp_subhandler_attr = 'mxs'
24     _comp_subhandler_class = MailExchange
25