Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3456166
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:42:11+00:00 2026-05-18T09:42:11+00:00

UPDATE: See the comment by systempuntoout . The form was missing the submit button.

  • 0

UPDATE:

See the comment by systempuntoout. The form was missing the submit button. Now it all works.


I have this code that I think would write an image to datastore; but that’s not happenning:

class AvatarSave(webapp.RequestHandler):
    def post(self):
        q = User.all()
        q.filter("userEmail =", "az@example.com")
        qTable = q.fetch(10)
        if qTable:
            for row in qTable:
                avatar = images.resize(self.request.get("img"), 32, 32)
                row.avatar = db.Blob(avatar)
                db.put(qTable)
        else:
            self.response.out.write("user not found")

        self.redirect('/')

The log shows the image key:

INFO     2010-12-04 13:56:26,601 dev_appserver.py:3317] "GET /img?
img_id=ag1oZWxsby0xLXdvcmxkcgsLEgRVc2VyGIABDA HTTP/1.1" 200 -

But nothing is displayed except the broken link. What am I missing here? I would appreciate your help. I include the entire script below. Thanks!

class MainPage(webapp.RequestHandler):
    def get(self):
        siteUser = users.get_current_user()
        greeting = None        
        if siteUser:
            greeting = ("Welcome, %s! (<a href=\"%s\">sign out</a>)" %
                    (siteUser.nickname(), users.create_logout_url("/")))
        else:
            greeting = ("<a href=\"%s\">Sign in or register</a>" %
                    users.create_login_url("/"))

        self.response.out.write(greeting)            

        self.response.out.write("""
          <form action="/avatar-save" enctype="multipart/form-data" method="post">                
            <div><label>Avatar:</label></div>
            <div><input type="file" name="img"/></div>
          </form>
        </body>
      </html>""")

        query = User.all()
        query.filter("userEmail =", "az@example.com")
        query.order("-userScore")
        results = query.fetch(10)
        self.response.out.write("""<html><head><style>
                               body {font-size: small;
                                     font-family: Verdana, Helvetica, sans-serif;
                                    }</style>
                                    </head><body><ol>""")
        for result in results:
            self.response.out.write("<li>")
            self.response.out.write("<b>%s</b> %s " % (result.userName, result.userLatestComment))
            self.response.out.write("<div><img src='img?img_id=%s'></img>" % result.key())
            self.response.out.write("</li>")
        self.response.out.write("</ol></body></html>")

class Image (webapp.RequestHandler):
    def get(self):
        greeting = db.get(self.request.get("img_id"))
        if greeting.avatar:
            self.response.headers['Content-Type'] = "image/png"
            self.response.out.write(greeting.avatar)
        else:
            self.response.out.write("No image")

class AvatarSave(webapp.RequestHandler):
    def post(self):
        q = User.all()
        q.filter("userEmail =", "az@example.com")
        qTable = q.fetch(10)
        if qTable:
            for row in qTable:
                avatar = images.resize(self.request.get("img"), 32, 32)
                row.avatar = db.Blob(avatar)
                db.put(qTable)
        else:
            self.response.out.write("user not found")

        self.redirect('/')

application = webapp.WSGIApplication(
                                     [('/', MainPage),
                                      ('/img', Image),
                                      ('/avatar-save', AvatarSave),                                      
                                      ],
                                     debug=True)

def main():
    run_wsgi_app(application)

if __name__ == "__main__":
    main()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T09:42:11+00:00Added an answer on May 18, 2026 at 9:42 am

    I think your code is missing the Submit button on the image form submission:

    self.response.out.write("""
              <form action="/avatar-save" enctype="multipart/form-data" method="post">                
                <div><label>Avatar:</label></div>
                <div><input type="file" name="img"/></div>
                <input type="submit"/>
              </form>...
    

    I’ve tried your code inferring the User model that you have not reported in the question:

    class User(db.Model):
        userEmail = db.EmailProperty()
        userScore = db.IntegerProperty()
        avatar = db.BlobProperty()
    

    since your code does not contain the part from creating the user, I have created a user from scratch from the Development interactive console with:

    from main import User
    User(userEmail='az@example.com', userScore=1).put()
    

    then, I’ve logged in with az@example.com and I’ve uploaded the picture.

    This is the result:
    alt text

    All I can say is “it works on my machine”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Update: The question title can be misleading. This was not Go's fault at all.
I have one Entity call Comment Comment + id (PK) + fromUserId + targetId
Using .NET 3.5, I'm finding that a CollectionView with a filter doesn't update when
I've read multiple sources that say Gridview's do not persist the Gridview.DataSource property on
I was just learning how to use the LINQ/EDM combination to retrieve and update
I have downloaded eclipse 3.4 (java version) for MacOSX (carbon). I have tried to
I'm trying to limit my program to take location updates every 10 seconds instead
I'm currently developing a game for Android and I want to take screenshots of
In chapter 7.7 (Punctuators) of the ECMAScript spec ( http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf ) the grid of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.