コード例 #1
0
ファイル: email.py プロジェクト: sabren/cornerops-svn
    def invoke(self, _clerk, _user, _sess, mailbox):
        if _user.plan.boxquota == Plan.UNLIMITED:
            pass
        else:
            assert _user.plan.boxquota != Plan.FORBIDDEN, \
                   "You don't have rights to add a new mailbox"
            assert len(_user.boxes) < _user.boxquota, \
                   "Adding a mailbox would exceed your quota."

        boxname = mailbox

        ## ensure we have a boxname:
        if not boxname:
            raise Intercept("a mailbox name is requried.")

        ## first check for duplicates (any user)
        if _clerk.match(Mailbox, mailbox=boxname):
            raise Intercept("box %s already exists" % boxname)

        ## string validation
        try:
            box = _user.boxes << Mailbox(mailbox=boxname)
        except ValueError:
            raise Intercept("invalid mailbox name.")

        ## now add it:
        try:
            passwd = _user.getBeaker().addpop(box.mailbox)
        except Exception, e:
            assert False, e  # @TODO: real error message
コード例 #2
0
    def invoke(self,
               _clerk,
               _user,
               domain,
               rectype,
               value,
               priority=0,
               ID=None):
        try:
            dom = safety.safeDomain(_user, domain)
            if ID:
                rec = safety.safeDNSRec(dom, ID)
            else:
                rec = DNSRec()

            if rec.domain is not dom:
                dom.dnsrecs << rec

            rec.rectype = rectype
            rec.priority = priority  # field might be disabled
            rec.value = value

            #@TODO: this is kludgy, but i can't put this in set_value
            # ...unless I split DNSRec into two classes...
            # ALSO, these should generally have a "." at the end!!
            from cornerhost.schema.Domain import reDomain
            if rectype == "MX" and not reDomain.match(rec.value):
                raise ValueError('value', rec.value)
            _clerk.store(rec)

        except (ValueError, TypeError), e:
            raise Intercept(e)
コード例 #3
0
 def invoke(self, _clerk, _user, domName, create_site=0, subName=''):
     try:
         #@TODO: NewSiteGrunt: ugh... :/
         self.grunt = NewSiteGrunt(_clerk, _user)
         dom = self.makeDomainObject(domName, subName)
     except (ValueError, TypeError), e:
         raise Intercept(e)
コード例 #4
0
ファイル: email.py プロジェクト: sabren/cornerops-svn
 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))
コード例 #5
0
ファイル: email.py プロジェクト: sabren/cornerops-svn
 def invoke(self, _user, _clerk, domName, rule, mailto):
     try:
         dom = safety.safeDomain(_user, domName)
         dom.mailto = self.compileRule(rule, mailto)
         _clerk.store(dom)
         _user.getBeaker().genmailconf()
     except ValueError, e:
         raise Intercept(self.ruleMessage(e))
コード例 #6
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)
コード例 #7
0
 def invoke(self, _user, crontab=""):
     if not crontab.endswith("\n"):
         crontab += "\n"
     error = _user.getBeaker().setcron(_user.username, crontab).strip()
     if error:
         if ":" in error:
             tempfilepath, line, msg = error.split(":", 2)
             error = "line %s: %s" % (line, msg)
         raise Intercept(error)
コード例 #8
0
class SetPasswordCommand(ControlPanelFeature):
    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)
        except socket.error, e:
            raise Intercept("socket error: %s" % e)
コード例 #9
0
ファイル: email.py プロジェクト: sabren/cornerops-svn
 def invoke(self,
            _clerk,
            _user,
            domName,
            mailto,
            rule='~',
            ID=0,
            virtuser='',
            oldVirt=''):
     if not virtuser.strip():
         raise Intercept("no mailbox name given")
     try:
         self.do_save_rule(_clerk=_clerk,
                           _user=_user,
                           ID=ID,
                           virtuser=virtuser,
                           oldVirt=oldVirt,
                           domName=domName,
                           mailto=self.compileRule(rule, mailto))
     except ValueError, e:
         raise Intercept(self.ruleMessage(e))
コード例 #10
0
 def invoke(self,
            _clerk,
            _user,
            name,
            rule,
            rectype,
            location,
            processmail=0):
     try:
         dom = safety.safeDomain(_user, name)
         dom.update(processmail=int(processmail),
                    rule=rule,
                    rectype=rectype,
                    location=location)
         _clerk.store(dom)
     except (TypeError, ValueError), e:
         raise Intercept(e)
コード例 #11
0
    def invoke(self,
               _clerk,
               _user,
               name,
               haserrs=0,
               suExec=0,
               docroot='',
               extra=None):

        s = safety.safeSiteByName(_user, name)
        try:
            s.docroot = docroot
            assert not hasattr(s.private,
                               "isStub"), "set_docroot didn't clear .isStub"
            assert s.docroot == docroot
            s.haserrs = haserrs
            s.suExec = suExec
            self._assignExtra(s, extra)
        except (ValueError, TypeError), e:
            raise Intercept(e)
コード例 #12
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))
コード例 #13
0
 def invoke(self, _user, _clerk, dbname):
     try:
         _user.getMySQL().createDatabase(_user.username, dbname)
     except ValueError, e:
         raise Intercept(str(e))
コード例 #14
0
            raise Intercept(error)


class SetPasswordCommand(ControlPanelFeature):
    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)
        except socket.error, e:
            raise Intercept("socket error: %s" % e)
        except (TypeError, ValueError, LookupError, IOError), e:
            raise Intercept(self.buildErrorMessage(e))


class AnalogFeature(ControlPanelFeature):
    # note: this is handle(), not invoke()!! special case!
    def invoke(self, _req, _res, _sess, _user):
        req, res, sess = _req, _res, _sess
        path = req.get("path")
        assert path, "no path given"
        try:
            ctype, content = _user.getBeaker().getContent(_user.username, path)
            res.addHeader("Content-Type", ctype)
            res.write(zlib.decompress(base64.decodestring(content)))
        except Exception, e:
            res.addHeader("Status", "404 Not Found")
            res.write("<h1>Not Found</h1>\n")