def post(self, key): checkkey = UploadRequestKeys.get(key) if not checkkey: self.error(404) if checkkey.expire_date < datetime.now(): self.error(404) img = self.request.get("img") # if we don't have image data we'll quit now if not img: return None try: width = int(self.request.get("width")) hight = int(self.request.get("height")) except ValueError: image_content = img else: image_content = images.resize(img, width, height) original_content = img thumb_content = images.resize(img, 100, 100) image = Image() image.image = db.Blob(image_content) image.original = db.Blob(original_content) image.thumb = db.Blob(thumb_content) image.user = users.get_current_user() image.realm = RealmKeys.get(checkkey.realm_key) image.put() checkkey.delete() # self.response.out.write(simplejson.dumps({'img_url'::})) context = { "image": True, "img_url": "http://org-images.appspot.com/i/img?id=%s" % image.key(), "thumb_url": "http://org-images.appspot.com/i/thumb?id=%s" % image.key(), } path = os.path.join(os.path.dirname(__file__), "templates", "show_links.html") # render the template with the provided context self.response.out.write(template.render(path, context))