def post(self): "Delete a given image" key = self.request.get("key") if key: image = Image.get_by_key_name_or_id(key) image.delete() # whatever happens rediect back to the main admin view self.redirect('/')
def get(self): # key is provided in the query string img = self.request.get("id") try: # it might be an invalid key so we better check image = Image.get_by_key_name_or_id(img) except db.BadKeyError: # if it is then return a 404 self.error(404) return if image and image.image: # we have an image so prepare the response # with the relevant headers self.response.headers['Content-Type'] = "image/png" # and then write our the image data direct to the response self.response.out.write(eval("image.%s" % self.property)) else: # we should probably return an image with the correct header # here instead of the default html 404 self.error(404)