* '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 MailLocation class to manage the mail_locationfor accounts."""fromconstants.VERSIONimportVERSION__author__='Pascal Volk <p.volk@veb-it.de>'__version__=VERSION__revision__='rev '+'$Rev$'.split()[1]__date__='$Date$'.split()[1]importrefromExceptionsimportVMMMailLocationExceptionasMLEimportconstants.ERRORasERRRE_MAILLOCATION="""^[\w]{1,20}$"""classMailLocation:"""A wrapper class thats provide access to the maillocation table"""def__init__(self,dbh,mid=None,maillocation=None):"""Creates a new MailLocation instance. Either mid or maillocation must be specified. Keyword arguments: dbh -- a pyPgSQL.PgSQL.connection mid -- the id of a maillocation (long) maillocation -- the value of the maillocation (str) """self._dbh=dbhifmidisNoneandmaillocationisNone:raiseMLE(_('Either mid or maillocation must be specified.'),ERR.MAILLOCATION_INIT)elifmidisnotNone:try:self.__id=long(mid)exceptValueError:raiseMLE(_('mid must be an int/long.'),ERR.MAILLOCATION_INIT)self._loadByID()else:re.compile(RE_MAILLOCATION)ifre.match(RE_MAILLOCATION,maillocation):self.__maillocation=maillocationself._loadByName()else:raiseMLE(_(u'Invalid folder name »%s«, it may consist only of\n\1 - 20 single byte characters (A-Z, a-z, 0-9 and _).')%maillocation,ERR.MAILLOCATION_INIT)def_loadByID(self):dbc=self._dbh.cursor()dbc.execute('SELECT maillocation FROM maillocation WHERE mid = %s',self.__id)result=dbc.fetchone()dbc.close()ifresultisnotNone:self.__maillocation=result[0]else:raiseMLE(_('Unknown mid specified.'),ERR.UNKNOWN_MAILLOCATION_ID)def_loadByName(self):dbc=self._dbh.cursor()dbc.execute('SELECT mid FROM maillocation WHERE maillocation = %s',self.__maillocation)result=dbc.fetchone()dbc.close()ifresultisnotNone:self.__id=result[0]else:self._save()def_save(self):dbc=self._dbh.cursor()dbc.execute("SELECT nextval('maillocation_id')")self.__id=dbc.fetchone()[0]dbc.execute('INSERT INTO maillocation(mid,maillocation) VALUES(%s,%s)',self.__id,self.__maillocation)self._dbh.commit()dbc.close()defgetID(self):"""Returns the unique ID of the maillocation."""returnself.__iddefgetMailLocation(self):"""Returns the value of maillocation, ex: 'Maildir'"""returnself.__maillocation