def post(self): blog_name = self.request.get('blog_name') upload_files = self.get_uploads('file') # 'file' is file upload field in the form blob_info = upload_files[0] pic = Picture(parent=main.blog_key(blog_name)) pic.data = blob_info.key() pic.put() self.redirect('/blog_gallery?blog_name='+blog_name)
def get(self): blog_name = self.request.get('blog_name') pics_query = Picture.query(ancestor=main.blog_key(blog_name)) pics = pics_query.fetch() upload_url = blobstore.create_upload_url('/upload') pic_urls = [] for pic in pics: pic_urls.append(images.get_serving_url(pic.data)) template_values={ 'upload_url': upload_url, 'pic_urls': pic_urls, 'blog_name': blog_name } template = main.JINJA_ENVIRONMENT.get_template('blog_gallery.html') self.response.write(template.render(template_values))