コード例 #1
0
 def invoke(self, _user, old, new1, new2):
     #@TODO: this ought to be universal or something. :/
     # it [was?] almost EXACTLY like SetBoxPasswordCommand
     try:
         _user.getBeaker().setpasswd(_user.username, old,
                                     extractNewPass(new1, new2))
     except xmlrpclib.Fault, f:
         raise Intercept(f.faultString)
コード例 #2
0
ファイル: remote.py プロジェクト: sabren/cornerops-svn
 def invoke(self, _user, old, new1, new2):
     #@TODO: this ought to be universal or something. :/
     # it [was?] almost EXACTLY like SetBoxPasswordCommand
     try:
         _user.getBeaker().setpasswd(
             _user.username, old, extractNewPass(new1, new2))
     except xmlrpclib.Fault, f:
         raise Intercept(f.faultString)
コード例 #3
0
ファイル: email.py プロジェクト: sabren/cornerops-svn
        _clerk.delete(Mailbox, box.ID)


class SetBoxPasswordCommand(ControlPanelFeature):
    # tests in test/SetBoxPasswordCommandTest

    def invoke(self, _user, mailbox, pass1, pass2):
        #@TODO: clean this mess up. this used to be do_invoke
        # it's here so we can test exceptions in invoke_x
        #also, this should probably be in remote.py
        try:
            return self.invoke_x(_user, mailbox, pass1, pass2)
        except (TypeError, ValueError, LookupError, IOError), e:
            raise Intercept(error=self.buildErrorMessage(e))

    def invoke_x(self, _user, mailbox, pass1, pass2):
        try:
            box = safety.safeMailbox(_user, mailbox)
        except AssertionError, e:
            raise LookupError(e)
        try:
            password = extractNewPass(pass1, pass2)
            _user.getBeaker().setboxpasswd(box.mailbox, password)
        except Fault, f:
            msg = f.faultString
            # trim "NO:" errors from beaker
            #@TODO: trap other beaker errors
            if msg.count("NO:"):
                msg = msg[msg.find("NO:"):]
            raise IOError(msg)  # so we can catch it
コード例 #4
0
 def invoke(self, _user, new1, new2):
     try:
         pwd = extractNewPass(new1, new2)
         if "'" in pwd: raise ValueError("invalid password")
     except ValueError, e:
         raise Intercept(str(e))
コード例 #5
0
ファイル: email.py プロジェクト: sabren/cornerops-svn
class SetBoxPasswordCommand(ControlPanelFeature):
    # tests in test/SetBoxPasswordCommandTest


    def invoke(self, _user, mailbox, pass1, pass2):
        #@TODO: clean this mess up. this used to be do_invoke
        # it's here so we can test exceptions in invoke_x
        #also, this should probably be in remote.py
        try:           
            return self.invoke_x(_user, mailbox, pass1, pass2)
        except (TypeError, ValueError, LookupError, IOError), e:
            raise Intercept(error=self.buildErrorMessage(e))

    
    def invoke_x(self, _user, mailbox, pass1, pass2):
        try:
            box = safety.safeMailbox(_user, mailbox)
        except AssertionError, e:
            raise LookupError(e)
        try:
            password = extractNewPass(pass1,pass2)
            _user.getBeaker().setboxpasswd(box.mailbox, password)
        except Fault, f:
            msg = f.faultString
            # trim "NO:" errors from beaker
            #@TODO: trap other beaker errors
            if msg.count("NO:"):
                msg = msg[msg.find("NO:"):]
            raise IOError(msg) # so we can catch it
コード例 #6
0
ファイル: remote.py プロジェクト: sabren/cornerops-svn
 def invoke(self, _user, new1, new2):
     try:
         pwd = extractNewPass(new1,new2)
         if "'" in pwd: raise ValueError("invalid password")
     except ValueError, e:
         raise Intercept(str(e))