示例#1
0
    def handle(self, designator):

        classname, itemid = hyperdb.splitDesignator(designator)

        # do the restore
        self.db.getclass(classname).restore(itemid)
        self.db.commit()
    def permission(self, designator):

        classname, itemid = hyperdb.splitDesignator(designator)

        if not self.db.security.hasPermission('Edit', self.db.getuid(),
                                              classname=classname, itemid=itemid):
            raise Unauthorised(self._('You do not have permission to '
                                      '%(action)s the %(classname)s class.')%info)
示例#3
0
    def permission(self, designator):

        classname, itemid = hyperdb.splitDesignator(designator)

        if not self.db.security.hasPermission(
                'Edit', self.db.getuid(), classname=classname, itemid=itemid):
            raise Unauthorised(
                self._('You do not have permission to '
                       'retire the %(classname)s class.') % classname)
示例#4
0
    def permission(self, designator):

        classname, itemid = hyperdb.splitDesignator(designator)
        perm = self.db.security.hasPermission

        if not perm('Retire', self.db.getuid(), classname=classname
                   , itemid=itemid):
            raise Unauthorised(self._('You do not have permission to retire '
                                      'or restore the %(classname)s class.')
                                      %locals())
示例#5
0
 def display(self, designator, *properties):
     classname, itemid = hyperdb.splitDesignator(designator)
     cl = self.db.getclass(classname)
     props = properties and list(properties) or cl.properties.keys()
     props.sort()
     for p in props:
         if not self.db.security.hasPermission("View", self.db.getuid(), classname, p, itemid):
             raise Unauthorised("Permission to view %s of %s denied" % (p, designator))
         result = [(prop, cl.get(itemid, prop)) for prop in props]
     return dict(result)
示例#6
0
 def display(self, designator, *properties):
     classname, itemid = hyperdb.splitDesignator(designator)
     cl = self.db.getclass(classname)
     props = properties and list(properties) or list(cl.properties.keys())
     props.sort()
     for p in props:
         if not self.db.security.hasPermission('View', self.db.getuid(),
                                               classname, p, itemid):
             raise Unauthorised('Permission to view %s of %s denied'%
                                (p, designator))
         result = [(prop, cl.get(itemid, prop)) for prop in props]
     return dict(result)
    def handle(self, designator):

        classname, itemid = hyperdb.splitDesignator(designator)

        # make sure we don't try to retire admin or anonymous
        if (classname == 'user' and
            self.db.user.get(itemid, 'username') in ('admin', 'anonymous')):
            raise ValueError, self._(
                'You may not retire the admin or anonymous user')

        # do the retire
        self.db.getclass(classname).retire(itemid)
        self.db.commit()
示例#8
0
    def handle(self, designator):

        classname, itemid = hyperdb.splitDesignator(designator)

        # make sure we don't try to retire admin or anonymous
        if (classname == 'user' and
            self.db.user.get(itemid, 'username') in ('admin', 'anonymous')):
            raise ValueError(self._(
                'You may not retire the admin or anonymous user'))

        # do the retire
        self.db.getclass(classname).retire(itemid)
        self.db.commit()
示例#9
0
    def set(self, designator, *args):

        classname, itemid = hyperdb.splitDesignator(designator)
        cl = self.db.getclass(classname)
        props = props_from_args(self.db, cl, args, itemid)  # convert types
        for p in props.iterkeys():
            if not self.db.security.hasPermission("Edit", self.db.getuid(), classname, p, itemid):
                raise Unauthorised("Permission to edit %s of %s denied" % (p, designator))
        try:
            result = cl.set(itemid, **props)
            self.db.commit()
        except (TypeError, IndexError, ValueError), message:
            raise UsageError, message
示例#10
0
文件: xmlrpc.py 项目: jerrykan/herder
    def set(self, designator, *args):

        classname, itemid = hyperdb.splitDesignator(designator)
        cl = self.db.getclass(classname)
        props = props_from_args(self.db, cl, args, itemid)  # convert types
        for p in props.iterkeys():
            if not self.db.security.hasPermission('Edit', self.db.getuid(),
                                                  classname, p, itemid):
                raise Unauthorised('Permission to edit %s of %s denied' %
                                   (p, designator))
        try:
            result = cl.set(itemid, **props)
            self.db.commit()
        except (TypeError, IndexError, ValueError), message:
            raise UsageError, message
示例#11
0
 def display(self, username, password, designator, *properties):
     r = RoundupRequest(self.tracker, username, password)
     try:
         classname, itemid = hyperdb.splitDesignator(designator)
         cl = r.get_class(classname)
         props = properties and list(properties) or cl.properties.keys()
         props.sort()
         for p in props:
             if not r.db.security.hasPermission('View', r.userid,
                     classname, p, itemid):
                 raise Unauthorised('Permission to view %s of %s denied'%
                         (p, designator))
         result = [(prop, cl.get(itemid, prop)) for prop in props]
     finally:
         r.close()
     return dict(result)
示例#12
0
 def display(self, username, password, designator, *properties):
     r = RoundupRequest(self.tracker, username, password)
     try:
         classname, itemid = hyperdb.splitDesignator(designator)
         cl = r.get_class(classname)
         props = properties and list(properties) or cl.properties.keys()
         props.sort()
         for p in props:
             if not r.db.security.hasPermission('View', r.userid, classname,
                                                p, itemid):
                 raise Unauthorised('Permission to view %s of %s denied' %
                                    (p, designator))
         result = [(prop, cl.get(itemid, prop)) for prop in props]
     finally:
         r.close()
     return dict(result)
示例#13
0
 def set(self, username, password, designator, *args):
     r = RoundupRequest(self.tracker, username, password)
     try:
         classname, itemid = hyperdb.splitDesignator(designator)
         cl = r.get_class(classname)
         props = r.props_from_args(cl, args, itemid) # convert types
         for p in props.iterkeys ():
             if not r.db.security.hasPermission('Edit', r.userid,
                     classname, p, itemid):
                 raise Unauthorised('Permission to edit %s of %s denied'%
                     (p, designator))
         try:
             return cl.set(itemid, **props)
         except (TypeError, IndexError, ValueError), message:
             raise UsageError, message
     finally:
         r.close()
示例#14
0
 def set(self, username, password, designator, *args):
     r = RoundupRequest(self.tracker, username, password)
     try:
         classname, itemid = hyperdb.splitDesignator(designator)
         cl = r.get_class(classname)
         props = r.props_from_args(cl, args)  # convert types
         for p in props.iterkeys():
             if not r.db.security.hasPermission('Edit', r.userid, classname,
                                                p, itemid):
                 raise Unauthorised('Permission to edit %s of %s denied' %
                                    (p, designator))
         try:
             return cl.set(itemid, **props)
         except (TypeError, IndexError, ValueError), message:
             raise UsageError, message
     finally:
         r.close()
示例#15
0
    def set(self, designator, *args):

        classname, itemid = hyperdb.splitDesignator(designator)
        cl = self.db.getclass(classname)
        props = props_from_args(self.db, cl, args, itemid) # convert types
        for p in props.keys():
            if not self.db.security.hasPermission('Edit', self.db.getuid(),
                                                  classname, p, itemid):
                raise Unauthorised('Permission to edit %s of %s denied'%
                                   (p, designator))
        try:
            result = cl.set(itemid, **props)
            self.db.commit()
        except (TypeError, IndexError, ValueError) as message:
            # The exception we get may be a real error, log the traceback if we're debugging
            logger = logging.getLogger('roundup.xmlrpc')
            for l in format_exc().split('\n'):
                logger.debug(l)
            raise UsageError (message)
        return result