VirtualMailManager/AliasDomain.py
changeset 56 9ae1b1b2ee5c
parent 55 15c873f94ba6
child 76 14c0a092d7d2
equal deleted inserted replaced
55:15c873f94ba6 56:9ae1b1b2ee5c
    34         dbc.close()
    34         dbc.close()
    35         if alias is not None:
    35         if alias is not None:
    36             self.__gid, primary = alias
    36             self.__gid, primary = alias
    37             if primary:
    37             if primary:
    38                 raise VADE(_(u"The domain »%s« is a primary domain.") %
    38                 raise VADE(_(u"The domain »%s« is a primary domain.") %
    39                         self.__name, ERR.DOMAIN_ALIAS_ISDOMAIN)
    39                         self.__name, ERR.ALIASDOMAIN_ISDOMAIN)
    40 
    40 
    41     def save(self):
    41     def save(self):
    42         if self.__gid > 0:
    42         if self.__gid > 0:
    43             raise VADE(_(u'The alias domain »%s« already exists.') %self.__name,
    43             raise VADE(_(u'The alias domain »%s« already exists.') %self.__name,
    44                 ERR.DOMAIN_ALIAS_EXISTS)
    44                 ERR.ALIASDOMAIN_EXISTS)
    45         if self._domain is None:
    45         if self._domain is None:
    46             raise VADE(_(u'No destination domain for alias domain denoted.'),
    46             raise VADE(_(u'No destination domain for alias domain denoted.'),
    47                     ERR.DOMAIN_ALIAS_NO_DOMDEST)
    47                     ERR.ALIASDOMAIN_NO_DOMDEST)
    48         if self._domain._id < 1:
    48         if self._domain._id < 1:
    49             raise VADE (_(u"The target domain »%s« doesn't exist yet.") %
    49             raise VADE (_(u"The target domain »%s« doesn't exist yet.") %
    50                     self._domain._name, ERR.NO_SUCH_DOMAIN)
    50                     self._domain._name, ERR.NO_SUCH_DOMAIN)
    51         dbc = self._dbh.cursor()
    51         dbc = self._dbh.cursor()
    52         dbc.execute('INSERT INTO domain_name (domainname, gid, is_primary)\
    52         dbc.execute('INSERT INTO domain_name (domainname, gid, is_primary)\
    69                     _(u'There is no primary domain for the alias domain »%s«.')\
    69                     _(u'There is no primary domain for the alias domain »%s«.')\
    70                             % self.__name, ERR.NO_SUCH_DOMAIN)
    70                             % self.__name, ERR.NO_SUCH_DOMAIN)
    71         else:
    71         else:
    72             raise VADE(
    72             raise VADE(
    73                   _(u"The alias domain »%s« doesn't exist yet.") % self.__name,
    73                   _(u"The alias domain »%s« doesn't exist yet.") % self.__name,
    74                   ERR.NO_SUCH_DOMAIN_ALIAS)
    74                   ERR.NO_SUCH_ALIASDOMAIN)
    75     
    75     
    76     def delete(self):
    76     def delete(self):
    77         if self.__gid > 0:
    77         if self.__gid > 0:
    78             dbc = self._dbh.cursor()
    78             dbc = self._dbh.cursor()
    79             dbc.execute('DELETE FROM domain_name WHERE domainname = %s \
    79             dbc.execute('DELETE FROM domain_name WHERE domainname = %s \
    81             if dbc.rowcount > 0:
    81             if dbc.rowcount > 0:
    82                 self._dbh.commit()
    82                 self._dbh.commit()
    83         else:
    83         else:
    84             raise VADE(
    84             raise VADE(
    85                   _(u"The alias domain »%s« doesn't exist yet.") % self.__name,
    85                   _(u"The alias domain »%s« doesn't exist yet.") % self.__name,
    86                   ERR.NO_SUCH_DOMAIN_ALIAS)
    86                   ERR.NO_SUCH_ALIASDOMAIN)
    87 
    87