def post(self): error = None try: upload = self.get_uploads()[0] email_hash = md5(self.user.email) avatar = Avatar.get_by_id(email_hash) if not avatar: avatar = Avatar.create(email_hash, avatar=upload.key()) else: avatar.avatar = upload.key() avatar.put() except: error = 'Error occurred during file upload' finally: self.redirect_to('dashboard', **({'error': error} if error else {}))
def post(self): error = None try: upload = self.get_uploads()[0] email_hash = md5(self.user.email) avatar = Avatar.get_by_id(email_hash) if not avatar: avatar = Avatar.create(email_hash, avatar=upload.key()) else: avatar.avatar = upload.key() avatar.put() except: error = 'Error occurred during file upload' finally: self.redirect_to('dashboard', **({ 'error': error } if error else {}))
def get(self, email_hash): avatar = Avatar.get_by_id(email_hash) if (not avatar) or (not blobstore.get(avatar.avatar)): self.abort(404) else: self.send_blob(avatar.avatar)