* 'VirtualMailManager/EmailAddress.py'
- Added to repository - to simplify/reduce address validation.
* 'VirtualMailManager/Relocated.py'
- Added to repository
* 'VirtualMailManager/Exceptions.py'
- Added exception classes for class EmailAddress and class Relocated
* 'VirtualMailManager/constants/ERROR.py'
- Updated
- Removed shebang
* 'VirtualMailManager/VirtualMailManager.py'
- Moved static methods chkLocalpart() and chkEmailAddress to new class
EmailAddress
- Added static methods accountExists(), aliasExists(), relocatedExists() and
_exists()
- Fixed a bug in VirtualMailManager._readpass()
- Integrated class EmailAddress
* 'VirtualMailManager/Alias.py'
- Integrated class EmailAddress
- Removed Alias._isAccount()
* 'VirtualMailManager/Account.py'
- Integrated class EmailAddress
- Removed Account._isAlias()
* 'VirtualMailManager/AliasDomain.py'
* 'VirtualMailManager/Config.py'
* 'VirtualMailManager/Domain.py'
* 'VirtualMailManager/MailLocation.py'
* 'VirtualMailManager/Transport.py'
* 'VirtualMailManager/constants/EXIT.py'
- Removed shebang
* 'vmm'
- more detailed error messages from alias_add()
# -*- coding: UTF-8 -*-# Copyright 2008 VEB IT# See COPYING for distribution information.# $Id$"""Virtual Mail Manager's Transport class to manage the transport fordomains and accounts."""fromconstants.VERSIONimportVERSION__author__='Pascal Volk <p.volk@veb-it.de>'__version__=VERSION__revision__='rev '+'$Rev$'.split()[1]__date__='$Date$'.split()[1]fromExceptionsimportVMMTransportExceptionimportconstants.ERRORasERRclassTransport:"""A wrapper class thats provide access to the transport table"""def__init__(self,dbh,tid=None,transport=None):"""Creates a new Transport instance. Either tid or transport must be specified. Keyword arguments: dbh -- a pyPgSQL.PgSQL.connection tid -- the id of a transport (long) transport -- the value of the transport (str) """self._dbh=dbhiftidisNoneandtransportisNone:raiseVMMTransportException(_('Either tid or transport must be specified.'),ERR.TRANSPORT_INIT)eliftidisnotNone:try:self.__id=long(tid)exceptValueError:raiseVMMTransportException(_('tid must be an int/long.'),ERR.TRANSPORT_INIT)self._loadByID()else:self.__transport=transportself._loadByName()def_loadByID(self):dbc=self._dbh.cursor()dbc.execute('SELECT transport FROM transport WHERE tid = %s',self.__id)result=dbc.fetchone()dbc.close()ifresultisnotNone:self.__transport=result[0]else:raiseVMMTransportException(_('Unknown tid specified.'),ERR.UNKNOWN_TRANSPORT_ID)def_loadByName(self):dbc=self._dbh.cursor()dbc.execute('SELECT tid FROM transport WHERE transport = %s',self.__transport)result=dbc.fetchone()dbc.close()ifresultisnotNone:self.__id=result[0]else:self._save()def_save(self):dbc=self._dbh.cursor()dbc.execute("SELECT nextval('transport_id')")self.__id=dbc.fetchone()[0]dbc.execute('INSERT INTO transport (tid, transport) VALUES (%s, %s)',self.__id,self.__transport)self._dbh.commit()dbc.close()defgetID(self):"""Returns the unique ID of the transport."""returnself.__iddefgetTransport(self):"""Returns the value of transport, ex: 'dovecot:'"""returnself.__transport