コード例 #1
0
 def post(self):
     upload_files = self.get_uploads("file")  # 'file' is file upload field in the form
     blob_info = upload_files[0]
     blobfile = BlobFile()
     blobfile.blobkey = blob_info.key()
     blobfile.name = blob_info.filename
     blobfile.user = users.get_current_user()
     blobfile.put()
     self.redirect("/")
コード例 #2
0
 def post(self):
     upload_files = self.get_uploads("file")  # 'file' is file upload field in the form
     blob_info = upload_files[0]
     blobfile = BlobFile()
     blobfile.blobkey = blob_info.key()
     blobfile.name = blob_info.filename
     blobfile.user = users.get_current_user()
     blobfile.put()
     context = {"image": False, "blob_url": "http://org-images.appspot.com/i/blob?id=%s" % blobfile.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))
コード例 #3
0
    def get(self):
        "Responds to GET requets with the admin interface"
        # query the datastore for images owned by
        # the current user. You can't see anyone elses images
        # in the admin

        test = geturl("http://org-images.appspot.com/remote/upload/image/[valid key]")  # add valid realmkey
        url = test.get_url()

        user = users.get_current_user()

        realms = RealmKeys.all()
        images = Image.all().filter("user ="******"-date")

        cssfilesq = File.all()
        jscriptfilesq = File.all()

        cssfiles = cssfilesq.filter("content_type =", "text/css").order("-date")
        jscriptfiles = jscriptfilesq.filter("content_type =", "text/x-c").order("-date")

        blobs = BlobFile.all()
        blobs.filter("user ="******"-date")

        # we are enforcing loggins so we know we have a user
        # we need the logout url for the frontend
        logout = users.create_logout_url("/")

        # prepare the context for the template
        context = {
            "testurl": url,
            "blobuploadurl": blobstore.create_upload_url("/upload/blob"),
            "blobs": blobs,
            "cssfiles": cssfiles,
            "jscriptfiles": jscriptfiles,
            "images": images,
            "logout": logout,
            "realms": realms,
        }
        # calculate the template path
        path = os.path.join(os.path.dirname(__file__), "templates", "index.html")
        # render the template with the provided context
        self.response.out.write(template.render(path, context))