100 (vmm.cfg: section "bin", option "%(option)s")') %{'binary': val,'option': opt}, |
100 (vmm.cfg: section "bin", option "%(option)s")') %{'binary': val,'option': opt}, |
101 ERR.NOT_EXECUTABLE) |
101 ERR.NOT_EXECUTABLE) |
102 |
102 |
103 def __dbConnect(self): |
103 def __dbConnect(self): |
104 """Creates a pyPgSQL.PgSQL.connection instance.""" |
104 """Creates a pyPgSQL.PgSQL.connection instance.""" |
105 try: |
105 if self.__dbh is None or not self.__dbh._isOpen: |
106 self.__dbh = PgSQL.connect( |
106 try: |
107 database=self.__Cfg.get('database', 'name'), |
107 self.__dbh = PgSQL.connect( |
108 user=self.__Cfg.get('database', 'user'), |
108 database=self.__Cfg.get('database', 'name'), |
109 host=self.__Cfg.get('database', 'host'), |
109 user=self.__Cfg.get('database', 'user'), |
110 password=self.__Cfg.get('database', 'pass'), |
110 host=self.__Cfg.get('database', 'host'), |
111 client_encoding='utf8', unicode_results=True) |
111 password=self.__Cfg.get('database', 'pass'), |
112 dbc = self.__dbh.cursor() |
112 client_encoding='utf8', unicode_results=True) |
113 dbc.execute("SET NAMES 'UTF8'") |
113 dbc = self.__dbh.cursor() |
114 dbc.close() |
114 dbc.execute("SET NAMES 'UTF8'") |
115 except PgSQL.libpq.DatabaseError, e: |
115 dbc.close() |
116 raise VMMException(str(e), ERR.DATABASE_ERROR) |
116 except PgSQL.libpq.DatabaseError, e: |
|
117 raise VMMException(str(e), ERR.DATABASE_ERROR) |
117 |
118 |
118 def idn2ascii(domainname): |
119 def idn2ascii(domainname): |
119 """Converts an idn domainname in punycode. |
120 """Converts an idn domainname in punycode. |
120 |
121 |
121 Keyword arguments: |
122 Keyword arguments: |
602 self.__mailDirMake(acc.getDir('domain'), acc.getUID(), acc.getGID()) |
603 self.__mailDirMake(acc.getDir('domain'), acc.getUID(), acc.getGID()) |
603 |
604 |
604 def aliasAdd(self, aliasaddress, targetaddress): |
605 def aliasAdd(self, aliasaddress, targetaddress): |
605 alias = self.__getAlias(aliasaddress, targetaddress) |
606 alias = self.__getAlias(aliasaddress, targetaddress) |
606 alias.save() |
607 alias.save() |
|
608 gid = self.__getDomain(alias._dest._domainname).getID() |
|
609 if gid > 0 and not VirtualMailManager.accountExists(self.__dbh, |
|
610 alias._dest): |
|
611 self.__warnings.append( |
|
612 _(u"The destination account »%s« doesn't exists yet.")%\ |
|
613 alias._dest) |
607 |
614 |
608 def userDelete(self, emailaddress, force=None): |
615 def userDelete(self, emailaddress, force=None): |
609 if force not in [None, 'delalias']: |
616 if force not in [None, 'delalias']: |
610 raise VMMException(_(u"Invalid argument: »%s«") % force, |
617 raise VMMException(_(u"Invalid argument: »%s«") % force, |
611 ERR.INVALID_AGUMENT) |
618 ERR.INVALID_AGUMENT) |