def _PUT(self, *param, **params): tag_id = param[0] if not validates_param_id(self, tag_id): self.logger.debug( "Failed to update tag. The value of parameter is invalid.") return web.badrequest(self.view.alert) if not validates_tag(self): self.logger.debug( "Failed to update tag. The value of input is invalid.") return web.badrequest(self.view.alert) tag = findby1(self.orm, tag_id) if not tag: self.logger.debug("Failed to update tag. No such tag - id=%s" % tag_id) return web.notfound() cmp_tag = findby1name(self.orm, self.input.name) if not cmp_tag is None: if cmp_tag.id != tag.id: self.logger.debug( "Failed to update tag. The same tag already exist - id='%s'" % (cmp_tag.id)) return web.conflict(web.ctx.path) tag.name = self.input.name update(self.orm, tag) return web.seeother(web.ctx.path)
def _PUT(self, *param, **params): tag_id = param[0] if not validates_param_id(self, tag_id): self.logger.debug("Failed to update tag. The value of parameter is invalid.") return web.badrequest(self.view.alert) if not validates_tag(self): self.logger.debug("Failed to update tag. The value of input is invalid.") return web.badrequest(self.view.alert) tag = findby1(self.orm, tag_id) if not tag: self.logger.debug("Failed to update tag. No such tag - id=%s" % tag_id) return web.notfound() cmp_tag = findby1name(self.orm, self.input.name) if not cmp_tag is None: if cmp_tag.id != tag.id: self.logger.debug("Failed to update tag. The same tag already exist - id='%s'" % (cmp_tag.id)) return web.conflict(web.ctx.path) tag.name = self.input.name update(self.orm, tag) return web.seeother(web.ctx.path)
def _DELETE(self, *param, **params): tag_id = param[0] if not validates_param_id(self, tag_id): self.logger.debug("Failed to delete tag. The value of parameter is invalid.") return web.badrequest(self.view.alert) tag = findby1(self.orm, tag_id) if not tag: self.logger.debug("Failed to delete tag. No such tag - id=%s" % tag_id) return web.notfound() delete(self.orm, tag) return web.seeother("/%s.%s" % ("tag", "part"))
def _GET(self, *param, **params): tag_id = param[0] if not validates_param_id(self, tag_id): self.logger.debug("Failed to get tag. The value of parameter is invalid.") return web.badrequest(self.view.alert) tag = findby1(self.orm, tag_id) if not tag: self.logger.debug("Failed to get tag. No such tag - id=%s" % tag_id) return web.notfound() self.view.tag = tag return True
def _DELETE(self, *param, **params): tag_id = param[0] if not validates_param_id(self, tag_id): self.logger.debug( "Failed to delete tag. The value of parameter is invalid.") return web.badrequest(self.view.alert) tag = findby1(self.orm, tag_id) if not tag: self.logger.debug("Failed to delete tag. No such tag - id=%s" % tag_id) return web.notfound() delete(self.orm, tag) return web.seeother("/%s.%s" % ("tag", "part"))
def _GET(self, *param, **params): tag_id = param[0] if not validates_param_id(self, tag_id): self.logger.debug( "Failed to get tag. The value of parameter is invalid.") return web.badrequest(self.view.alert) tag = findby1(self.orm, tag_id) if not tag: self.logger.debug("Failed to get tag. No such tag - id=%s" % tag_id) return web.notfound() self.view.tag = tag return True