1

GWT/GAE 中的 Blobstore 可以用作数据库吗?还是每次启动应用程序时都会创建一个新的 Blobstore?我想在应用程序关闭时存储信息而不会丢失它。但我似乎找不到一种方法来命名 Blobstore,然后通过它的 ID 引用它。谢谢!

4

1 回答 1

0

如果您只想存储一个字符串,我仍然建议您使用数据存储。

以下是 App Engine 应用程序的完整 Python 源代码,该应用程序在数据存储区中检索、修改和存储一些文本:

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()

如果您使用 Java,它会更冗长,但类似。

于 2011-04-24T15:11:30.847 回答