I have made user registration which includes (name, password, email, phone no) and now trying to include image too in Google App engine datastore. Everything is working fine just image uploading and resizing was troublesome. But, I have make it work now.
Basically there are three handlers
- First one for registration page handler (information testing and redirecting to userpage)
“””Get all requests from registration page and store in database”””
userinfo.put() u_id = userinfo.key().id()“””create cookie and hash where value is u_id”””
self.redirect(/userpage)
- Second is userpage handler (which validate cookie created in registration handler, if hash cookie is valid then redirect to userpage else redirect to registration page again)
user_id = Users.get_by_id(u_id) user_key = ? # how can I get key of user_id
self.render("user.html", user =user_id.user, avatar = user_id.avatar)
- Third is image handler
class disp_image(webapp.RequestHandler): def get(self): key = self.request.get('key') image = Users.get(key) self.response.headers['Content-Type'] = "image/png" return self.response.out.write(image.avatar)
Template
<img src="/disp?key={{avatar}}" />
I have already solve the problem, revision was made to make it more clear for who have down-voted my question earlier.
user_key = user_id.key()But why is your head spinning? What are you actually trying to accomplish?