Almacenamiento de datos en el motor de aplicaciones de Google con problemas de Python

I am attempting to store data via python on the datastore.. but i am not succeeding.

I have looked at the documentation but still cannot manage to get my app working.

I have the following code which should define some data. put it to the appspot domain. and some django which should display the data(but uncertain as how to do this).

from google.appengine.ext import db
# A Model for a User
class Pokemondata(db.Model):
name = db.StringProperty()
pokemon= User(name="balbasaur")

class ApplyHandler(webapp.RequestHandler):
  def post(self):
   pname = self.request.get('name')

   pokemon= User(name=pname,acct=xacct,pw=xpw);
   self.session['pokemon'] = pname

  def get(self):
   que = db.Query(Pokemondata)

   poke_list = que.fetch(limit=5)

   Page = """
    <html manifest="my.manifest">


       <h1>%s's App Engine App</h>


   application = webapp.WSGIApplication([('/', User),
                                         ('/json', ApplyHandler)], debug=True)
  def Addlist():

   if __name__ == "__Addlist__":

I am unsure as how to display the data. Any advice would be appreicated

Muchas Gracias


preguntado el 05 de mayo de 13 a las 17:05

Please fix your indentation. And your program structure appears to be nonsense: why have you got the application object defined inside a method, and why are you calling run_wsgi_app? And why, if you've defined a Pokemondata model, are you instantiating and saving a User? -

you get method doesn't really do anything. You should be using self.response.write() to in addition you have define Page as a string, but you aren't doing anything with it. I would go back to the basic tutorials and work through them first. -

1 Respuestas

I can try and help but fist just get something really simple working, like:

file -> The white space on the left is very important in python (or tabs)

import webapp2
class MainPage(webapp2.RequestHandler):
    def get(self):
        self.response.headers['Content-Type'] = 'text/plain'
        self.response.write('Hello, webapp2 World!')

app = webapp2.WSGIApplication([('/', MainPage)],

and the app.yaml file: Both file must live in the same directory!

application: helloworld
version: 1
runtime: python27
api_version: 1
threadsafe: true

 - url: /.*

Then in the same directory you start .

Here is the link I am copying from

Go through the tutorial, don't get impatient and you will get going very soon You will progress to templates, static files and data models

contestado el 05 de mayo de 13 a las 20:05

hi i appreciate your replies. - Atomwiser

What i am doing is a uni project. The code was edited from my lectures example code which i am really intensely trying to understand. (we have never done python before at this level) - Atomwiser

the indentation fixes when i laod it in wings IDE so it must be an error in the indent for this site - Atomwiser

Go through the tutorial and then you should be able to complete your assignment - user784435

Thanks! doing just that right now. I have the hello world working. - Atomwiser

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.