Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
257 views
in Technique[技术] by (71.8m points)

python 2.7 - App Engine local datastore content does not persist

I'm running some basic test code, with web.py and GAE (Windows 7, Python27). The form enables messages to be posted to the datastore. When I stop the app and run it again, any data posted previously has disappeared. Adding entities manually using the admin (http://localhost:8080/_ah/admin/datastore) has the same problem.

I tried setting the path in the Application Settings using Extra flags:

--datastore_path=D:/path/to/app/

(Wasn't sure about syntax there). It had no effect. I searched my computer for *.datastore, and couldn't find any files, either, which seems suspect, although the data is obviously being stored somewhere for the duration of the app running.

from google.appengine.ext import db
import web

urls = (
    '/', 'index',
    '/note', 'note',
    '/crash', 'crash'
)

render = web.template.render('templates/')

class Note(db.Model):
    content = db.StringProperty(multiline=True)
    date = db.DateTimeProperty(auto_now_add=True)

class index:
    def GET(self):
            notes = db.GqlQuery("SELECT * FROM Note ORDER BY date DESC LIMIT 10")
            return render.index(notes)

class note:
    def POST(self):
            i = web.input('content')
            note = Note()
            note.content = i.content
            note.put()
            return web.seeother('/')

class crash:
    def GET(self):
            import logging
            logging.error('test')
            crash

app = web.application(urls, globals())

def main():
    app.cgirun()

if __name__ == '__main__':
  main()

UPDATE: When I run it via command line, I get the following:

WARNING  2012-04-06 19:07:31,266 rdbms_mysqldb.py:74] The rdbms API is not available because the MySQLdb library could not be loaded.
INFO     2012-04-06 19:07:31,778 appengine_rpc.py:160] Server: appengine.google.com
WARNING  2012-04-06 19:07:31,783 datastore_file_stub.py:513] Could not read datastore data from c:usersamyappdatalocalempdev_appserver.datastore
WARNING  2012-04-06 19:07:31,851 dev_appserver.py:3394] Could not initialize images API; you are likely missing the Python "PIL" module. ImportError: No module named _imaging
INFO     2012-04-06 19:07:32,052 dev_appserver_multiprocess.py:647] Running application dev~palimpsest01 on port 8080: http://localhost:8080
INFO     2012-04-06 19:07:32,052 dev_appserver_multiprocess.py:649] Admin console is available at: http://localhost:8080/_ah/admin

Suggesting that the datastore... didn't install properly?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...