VirtualMailManager/MailLocation.py
changeset 87 f9090d1a0730
parent 76 14c0a092d7d2
child 102 485d3f7d6981
equal deleted inserted replaced
86:e43e4e7e9ec0 87:f9090d1a0730
    16 import re
    16 import re
    17 
    17 
    18 from Exceptions import VMMMailLocationException as MLE
    18 from Exceptions import VMMMailLocationException as MLE
    19 import constants.ERROR as ERR
    19 import constants.ERROR as ERR
    20 
    20 
    21 RE_MAILLOCATION = """^[\w]{1,20}$"""
    21 RE_MAILLOCATION = """^\w{1,20}$"""
    22 
    22 
    23 class MailLocation:
    23 class MailLocation:
    24     """A wrapper class thats provide access to the maillocation table"""
    24     """A wrapper class thats provide access to the maillocation table"""
    25     def __init__(self, dbh, mid=None, maillocation=None):
    25     def __init__(self, dbh, mid=None, maillocation=None):
    26         """Creates a new MailLocation instance.
    26         """Creates a new MailLocation instance.
    41                 self.__id = long(mid)
    41                 self.__id = long(mid)
    42             except ValueError:
    42             except ValueError:
    43                 raise MLE(_('mid must be an int/long.'), ERR.MAILLOCATION_INIT)
    43                 raise MLE(_('mid must be an int/long.'), ERR.MAILLOCATION_INIT)
    44             self._loadByID()
    44             self._loadByID()
    45         else:
    45         else:
    46             re.compile(RE_MAILLOCATION)
       
    47             if re.match(RE_MAILLOCATION, maillocation):
    46             if re.match(RE_MAILLOCATION, maillocation):
    48                 self.__maillocation = maillocation
    47                 self.__maillocation = maillocation
    49                 self._loadByName()
    48                 self._loadByName()
    50             else:
    49             else:
    51                 raise MLE(
    50                 raise MLE(