VirtualMailManager/Domain.py
changeset 142 28f26f7f3d8f
parent 138 617f27715b01
child 155 eb866ebb9f2e
equal deleted inserted replaced
141:ecd6a379e523 142:28f26f7f3d8f
   229  local_part", self._id)
   229  local_part", self._id)
   230         users = dbc.fetchall()
   230         users = dbc.fetchall()
   231         dbc.close()
   231         dbc.close()
   232         accounts = []
   232         accounts = []
   233         if len(users) > 0:
   233         if len(users) > 0:
   234             for account in users:
   234             addr = u'@'.join
   235                 accounts.append('%s@%s' % (account[0], self._name))
   235             _dom = self._name
       
   236             accounts = [addr((account[0], _dom)) for account in users]
   236         return accounts
   237         return accounts
   237 
   238 
   238     def getAliases(self):
   239     def getAliases(self):
   239         """Returns a list with all aliases from the domain."""
   240         """Returns a list with all aliases from the domain."""
   240         dbc = self._dbh.cursor()
   241         dbc = self._dbh.cursor()
   242  ORDER BY address",  self._id)
   243  ORDER BY address",  self._id)
   243         addresses = dbc.fetchall()
   244         addresses = dbc.fetchall()
   244         dbc.close()
   245         dbc.close()
   245         aliases = []
   246         aliases = []
   246         if len(addresses) > 0:
   247         if len(addresses) > 0:
   247             for alias in addresses:
   248             addr = u'@'.join
   248                 aliases.append('%s@%s' % (alias[0], self._name))
   249             _dom = self._name
       
   250             aliases = [addr((alias[0], _dom)) for alias in addresses]
   249         return aliases
   251         return aliases
   250 
   252 
   251     def getRelocated(self):
   253     def getRelocated(self):
   252         """Returns a list with all addresses from relocated users."""
   254         """Returns a list with all addresses from relocated users."""
   253         dbc = self._dbh.cursor()
   255         dbc = self._dbh.cursor()
   255  ORDER BY address", self._id)
   257  ORDER BY address", self._id)
   256         addresses = dbc.fetchall()
   258         addresses = dbc.fetchall()
   257         dbc.close()
   259         dbc.close()
   258         relocated = []
   260         relocated = []
   259         if len(addresses) > 0:
   261         if len(addresses) > 0:
   260             for address in addresses:
   262             addr = u'@'.join
   261                 relocated.append('%s@%s' % (address[0], self._name))
   263             _dom = self._name
       
   264             relocated = [addr((address[0], _dom)) for address in addresses]
   262         return relocated
   265         return relocated
   263 
   266 
   264     def getAliaseNames(self):
   267     def getAliaseNames(self):
   265         """Returns a list with all alias names from the domain."""
   268         """Returns a list with all alias names from the domain."""
   266         dbc = self._dbh.cursor()
   269         dbc = self._dbh.cursor()
   268  AND NOT is_primary ORDER BY domainname", self._id)
   271  AND NOT is_primary ORDER BY domainname", self._id)
   269         anames = dbc.fetchall()
   272         anames = dbc.fetchall()
   270         dbc.close()
   273         dbc.close()
   271         aliasdomains = []
   274         aliasdomains = []
   272         if len(anames) > 0:
   275         if len(anames) > 0:
   273             for aname in anames:
   276             aliasdomains = [aname[0] for aname in anames]
   274                 aliasdomains.append(aname[0])
       
   275         return aliasdomains
   277         return aliasdomains
   276 
   278 
   277 def search(dbh, pattern=None, like=False):
   279 def search(dbh, pattern=None, like=False):
   278     if pattern is not None and like is False:
   280     if pattern is not None and like is False:
   279         pattern = VMM.VirtualMailManager.chkDomainname(pattern)
   281         pattern = VMM.VirtualMailManager.chkDomainname(pattern)