613 lpattern = parts[0] |
613 lpattern = parts[0] |
614 llike = lpattern.startswith('%') or lpattern.endswith('%') |
614 llike = lpattern.startswith('%') or lpattern.endswith('%') |
615 dpattern = parts[1] |
615 dpattern = parts[1] |
616 dlike = dpattern.startswith('%') or dpattern.endswith('%') |
616 dlike = dpattern.startswith('%') or dpattern.endswith('%') |
617 |
617 |
618 if llike: |
618 checkp = lpattern.strip('%') if llike else lpattern |
619 checkp = lpattern.strip('%') |
|
620 else: |
|
621 checkp = lpattern |
|
622 if len(checkp) > 0 and re.search(RE_LOCALPART, checkp): |
619 if len(checkp) > 0 and re.search(RE_LOCALPART, checkp): |
623 raise VMMError(_(u"The pattern '%s' contains invalid " |
620 raise VMMError(_(u"The pattern '%s' contains invalid " |
624 u"characters.") % pattern, |
621 u"characters.") % pattern, |
625 LOCALPART_INVALID) |
622 LOCALPART_INVALID) |
626 else: |
623 else: |
627 # else just match on domains |
624 # else just match on domains |
628 # (or should that be local part, I don't know…) |
625 # (or should that be local part, I don't know…) |
629 dpattern = parts[0] |
626 dpattern = parts[0] |
630 dlike = dpattern.startswith('%') or dpattern.endswith('%') |
627 dlike = dpattern.startswith('%') or dpattern.endswith('%') |
631 |
628 |
632 if dlike: |
629 checkp = dpattern.strip('%') if dlike else dpattern |
633 checkp = dpattern.strip('%') |
|
634 else: |
|
635 checkp = dpattern |
|
636 if len(checkp) > 0 and not re.match(RE_DOMAIN_SEARCH, checkp): |
630 if len(checkp) > 0 and not re.match(RE_DOMAIN_SEARCH, checkp): |
637 raise VMMError(_(u"The pattern '%s' contains invalid " |
631 raise VMMError(_(u"The pattern '%s' contains invalid " |
638 u"characters.") % pattern, DOMAIN_INVALID) |
632 u"characters.") % pattern, DOMAIN_INVALID) |
639 self._db_connect() |
633 self._db_connect() |
640 from VirtualMailManager.common import search_addresses |
634 from VirtualMailManager.common import search_addresses |
853 INVALID_ARGUMENT) |
847 INVALID_ARGUMENT) |
854 acc = self._get_account(emailaddress) |
848 acc = self._get_account(emailaddress) |
855 if not acc: |
849 if not acc: |
856 raise VMMError(_(u"The account '%s' does not exist.") % |
850 raise VMMError(_(u"The account '%s' does not exist.") % |
857 acc.address, NO_SUCH_ACCOUNT) |
851 acc.address, NO_SUCH_ACCOUNT) |
858 if transport == 'domain': |
852 transport = None if transport == 'domain' \ |
859 transport = None |
853 else Transport(self._dbh, transport=transport) |
860 else: |
|
861 transport = Transport(self._dbh, transport=transport) |
|
862 acc.update_transport(transport) |
854 acc.update_transport(transport) |
863 |
855 |
864 def user_services(self, emailaddress, *services): |
856 def user_services(self, emailaddress, *services): |
865 """Wrapper around Account.update_serviceset().""" |
857 """Wrapper around Account.update_serviceset().""" |
866 acc = self._get_account(emailaddress) |
858 acc = self._get_account(emailaddress) |