导入 cgi
导入 datetime
导入 logging
从 google.appengine.ext 导入 db
从 google.appengine.api 导入 users
从 google.appengine.ext 导入 webapp
从 google.appengine.ext.webapp.util 导入 run_wsgi_app
从 google.appengine.api 导入 images
class Photo(db.Model):
作者 = db.UserProperty ()
内容 = db.StringProperty (multiline=True)
imgBlob = db.BlobProperty()
日期 = db.DateTimeProperty (auto_now_add=True)
query_str = "SELECT * FROM Photo ORDER BY date DESC LIMIT 10"
photos = db.GqlQuery(query_str)
for photo in photos:
print photo.author.email()
print photo.content
photo.imgBlob=db.Blob(open("./img/go.jpg").read())
photo.put()