def post(self): self.delete_old_temp_image() timage = TempImage() timage.image=db.Blob(self.request.get("image")) timage.thumbnail=db.Blob(self.request.get("thumbnail")) timage.date=datetime.datetime.today() if(self.request.get("args")): timage.args=self.request.get("args") else: timage.args=None timage.put() self.response.headers ['Content-type'] = "text/html;charset=utf-8"; return_code="success&"+str(timage.key()) self.response.out.write(return_code);
def delete_old_temp_image(self): temp_image_list=TempImage.all().order("-date").fetch(limit=10) for temp_image in temp_image_list: from_last_update=(UploadTemp.get_sec(datetime.datetime.now())-UploadTemp.get_sec(temp_image.date))/60 if(from_last_update>=60): temp_image.delete()