VirtualMailManager/handler.py
branchv0.7.x
changeset 686 5f4abdab738e
parent 681 4cab983479db
child 694 b1bfd4d1d9c0
equal deleted inserted replaced
685:c6024bc1de0f 686:5f4abdab738e
   429         namespace."""
   429         namespace."""
   430         import builtins
   430         import builtins
   431         assert 'cfg_dget' not in builtins.__dict__
   431         assert 'cfg_dget' not in builtins.__dict__
   432         builtins.__dict__['cfg_dget'] = self._cfg.dget
   432         builtins.__dict__['cfg_dget'] = self._cfg.dget
   433 
   433 
   434     def domain_add(self, domainname, transport=None):
   434     def domain_add(self, domainname, transport=None, note=None):
   435         """Wrapper around Domain's set_quotalimit, set_transport and save."""
   435         """Wrapper around Domain's set_quotalimit, set_transport and save."""
   436         dom = self._get_domain(domainname)
   436         dom = self._get_domain(domainname)
   437         if transport is None:
   437         if transport is None:
   438             dom.set_transport(Transport(self._dbh,
   438             dom.set_transport(Transport(self._dbh,
   439                               transport=self._cfg.dget('domain.transport')))
   439                               transport=self._cfg.dget('domain.transport')))
   440         else:
   440         else:
   441             dom.set_transport(Transport(self._dbh, transport=transport))
   441             dom.set_transport(Transport(self._dbh, transport=transport))
       
   442         if note:
       
   443             dom.set_note(note)
   442         dom.set_quotalimit(QuotaLimit(self._dbh,
   444         dom.set_quotalimit(QuotaLimit(self._dbh,
   443                            bytes=int(self._cfg.dget('domain.quota_bytes')),
   445                            bytes=int(self._cfg.dget('domain.quota_bytes')),
   444                            messages=self._cfg.dget('domain.quota_messages')))
   446                            messages=self._cfg.dget('domain.quota_messages')))
   445         dom.set_serviceset(ServiceSet(self._dbh,
   447         dom.set_serviceset(ServiceSet(self._dbh,
   446                                       imap=self._cfg.dget('domain.imap'),
   448                                       imap=self._cfg.dget('domain.imap'),
   624         from VirtualMailManager.common import search_addresses
   626         from VirtualMailManager.common import search_addresses
   625         return search_addresses(self._dbh, typelimit=typelimit,
   627         return search_addresses(self._dbh, typelimit=typelimit,
   626                                 lpattern=lpattern, llike=llike,
   628                                 lpattern=lpattern, llike=llike,
   627                                 dpattern=dpattern, dlike=dlike)
   629                                 dpattern=dpattern, dlike=dlike)
   628 
   630 
   629     def user_add(self, emailaddress, password):
   631     def user_add(self, emailaddress, password, note=None):
   630         """Wrapper around Account.set_password() and Account.save()."""
   632         """Wrapper around Account.set_password() and Account.save()."""
   631         acc = self._get_account(emailaddress)
   633         acc = self._get_account(emailaddress)
   632         if acc:
   634         if acc:
   633             raise VMMError(_("The account '%s' already exists.") %
   635             raise VMMError(_("The account '%s' already exists.") %
   634                            acc.address, ACCOUNT_EXISTS)
   636                            acc.address, ACCOUNT_EXISTS)
   635         self._is_other_address(acc.address, TYPE_ACCOUNT)
   637         self._is_other_address(acc.address, TYPE_ACCOUNT)
   636         acc.set_password(password)
   638         acc.set_password(password)
       
   639         if note:
       
   640             acc.set_note(note)
   637         acc.save()
   641         acc.save()
   638         self._make_account_dirs(acc)
   642         self._make_account_dirs(acc)
   639 
   643 
   640     def alias_add(self, aliasaddress, *targetaddresses):
   644     def alias_add(self, aliasaddress, *targetaddresses):
   641         """Creates a new `Alias` entry for the given *aliasaddress* with
   645         """Creates a new `Alias` entry for the given *aliasaddress* with