#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    1
    Rep Power
    0

    Python and google app engine datastore issue


    up vote
    0
    down vote
    favorite
    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")
    pokemon.put()

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

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

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

    poke_list = que.fetch(limit=5)

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

    <body>

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

    </body>
    </html>
    """

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

    if __name__ == "__Addlist__":
    main()
    I am unsure as how to display the data. Any advice would be appreicated

    Thanks

    J
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    39
    Rep Power
    3
    It is very hard to follow your code as there is no indentation. However as this is a WSGI server, a response is done with the
    self.response.write() method.

    I would suggest working through a few WSGI tutorials. Once you understand them adding a datastore should be simple.

IMN logo majestic logo threadwatch logo seochat tools logo