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)
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)
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())
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)
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()
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()
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
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
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)
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)
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()
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()
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