开发者

Using GWT/GAE Blobstore as a database

开发者 https://www.devze.com 2023-02-28 02:46 出处:网络
Can the Blobstore in GWT/GAE be used as a database? Or is a new Blobstore created each time I launch the application? I would like to store information without losing it when the application is closed

Can the Blobstore in GWT/GAE be used as a database? Or is a new Blobstore created each time I launch the application? I would like to store information without losing it when the application is closed. But I can't seem to find a way to n开发者_Go百科ame a Blobstore and then reference it by its ID. Thanks!


If all you want to do is store a string I'd still suggest using the datastore.

Here's the complete python source to an App Engine app that retrieves, modifies, and stores some text in the datastore:

from google.appengine.ext import webapp, db
from google.appengine.ext.webapp import util    

class TextDoc(db.Model):
    text = db.TextProperty(default="")

class MainHandler(webapp.RequestHandler):
    def get(self):
        my_text_doc = TextDoc.get_or_insert('my_text_doc')

        my_text_doc.text += "Blah, blah, blah. "
        my_text_doc.put()

        self.response.out.write(my_text_doc.text)


def main():
    application = webapp.WSGIApplication([('/', MainHandler)],
                                         debug=True)
    util.run_wsgi_app(application)


if __name__ == '__main__':
    main()

If you're working in Java it would be more verbose, but similar.

0

精彩评论

暂无评论...
验证码 换一张
取 消