* 'VirtualMailManager/VirtualMailManager.py'
- Implemented:
+ VirtualMailManager.domain_alias_add()
+ VirtualMailManager.domain_alias_delete()
* 'VirtualMailManager/Domain.py'
- Implemented:
+ Domain._aliasExists()
+ Domain.saveAlias()
+ deleteAlias()
- Fixed Domain._exists(); returns only True when the domain exists
AND it's the primary domain
- Fixed table order in Domain.delete()
* 'vmm'
- _printList() added ace2idna support for alias domains
- Implemented:
+ domain_alias_add()
+ domain_alias_delete()
#!/usr/bin/env python# -*- coding: UTF-8 -*-# Copyright 2007-2008 VEB IT# See COPYING for distribution information.# $Id$"""Configurtion class for read, modify and write theconfiguration from Virtual Mail Manager."""fromconstants.VERSIONimportVERSION__author__='Pascal Volk <p.volk@veb-it.de>'__version__=VERSION__revision__='rev '+'$Rev$'.split()[1]__date__='$Date$'.split()[1]importsysimportgettextfromshutilimportcopy2fromConfigParserimportConfigParserfromcStringIOimportStringIOfromExceptionsimportVMMConfigExceptionimportconstants.ERRORasERRgettext.bindtextdomain('vmm','/usr/local/share/locale')gettext.textdomain('vmm')_=gettext.gettextclassVMMConfig(ConfigParser):"""This class is for configure the Virtual Mail Manager. You can specify settings for the database connection and maildirectories. """def__init__(self,filename):"""Creates a new VMMConfig instance Keyword arguments: filename -- name of the configuration file """ConfigParser.__init__(self)self.__cfgFileName=filenameself.__cfgFile=Noneself.__VMMsections=['database','maildir','services','domdir','bin','misc','config']self.__changes=Falseself.__missing={}self.__dbopts=[['host','localhot'],['user','vmm'],['pass','your secret password'],['name','mailsys']]self.__mdopts=[['folder','Maildir'],['mode',448],['diskusage','false'],['delete','false']]self.__serviceopts=[['smtp','true'],['pop3','true'],['imap','true'],['managesieve','true']]self.__domdopts=[['base','/srv/mail'],['mode',504],['delete','false']]self.__binopts=[['dovecotpw','/usr/sbin/dovecotpw'],['du','/usr/bin/du']]self.__miscopts=[['passwdscheme','PLAIN'],['gid_mail',8],['forcedel','false'],['transport','dovecot:']]defload(self):"""Loads the configuration, r/o"""try:self.__cfgFile=file(self.__cfgFileName,'r')except:raiseself.readfp(self.__cfgFile)self.__cfgFile.close()defcheck(self):ifnotself.__chkSections():errmsg=StringIO()fork,vinself.__missing.items():ifv[0]isTrue:errmsg.write(_("missing section: %s\n")%k)else:errmsg.write(_("missing options in section %s:\n")%k)foroinv:errmsg.write(" * %s\n"%o)raiseVMMConfigException((errmsg.getvalue(),ERR.CONF_ERROR))defgetsections(self):"""Return a list with all configurable sections."""returnself.__VMMsections[:-1]defconfigure(self,sections):"""Interactive method for configuring all options in the given section Keyword arguments: sections -- list of strings """ifnotisinstance(sections,list):raiseTypeError(_("Argument 'sections' is not a list."))# if [config] done = false (default at 1st run),# then set changes truetry:ifnotself.getboolean('config','done'):self.__changes=TrueexceptValueError:self.set('config','done','False')self.__changes=Trueforsinsections:ifs=='config':passelse:print_('* Config section: %s')%sforopt,valinself.items(s):newval=raw_input(_('Enter new value for %s [%s]: ')%(opt,val))ifnewvalandnewval!=val:self.set(s,opt,newval)self.__changes=Trueprintifself.__changes:self.__saveChanges()def__saveChanges(self):"""Writes changes to the configuration file."""self.set('config','done','true')copy2(self.__cfgFileName,self.__cfgFileName+'.bak')self.__cfgFile=file(self.__cfgFileName,'w')self.write(self.__cfgFile)self.__cfgFile.close()def__chkSections(self):"""Checks if all configuration sections are existing."""errors=Falseforsinself.__VMMsections:ifnotself.has_section(s):self.__missing[s]=[True]elifnotself.__chkOptions(s):errors=Truereturnnoterrorsdef__chkOptions(self,section):"""Checks if all configuration options in section are existing. Keyword arguments: section -- the section to be checked """retval=Truemissing=[]ifsection=='database':opts=self.__dboptselifsection=='maildir':opts=self.__mdoptselifsection=='services':opts=self.__serviceoptselifsection=='domdir':opts=self.__domdoptselifsection=='bin':opts=self.__binoptselifsection=='misc':opts=self.__miscoptselifsection=='config':opts=[['done','false']]foro,vinopts:ifnotself.has_option(section,o):missing.append(o)retval=Falseiflen(missing):self.__missing[section]=missingreturnretval