如何从gae数据存储中检索电子邮件?
问题描述:
我正在使用谷歌数据存储和jinja2开始。我能够添加和检索字符串值,但是当我使用电子邮件属性时: 电子邮件= db.Email 并使用.email检索它,我从数据存储区获得 类'google.appengine.api.datastore_types.Email' 。 我如何获得电子邮件的价值?如何从gae数据存储中检索电子邮件?
答
使用.email适合我。
Python代码
import webapp2
from google.appengine.ext import db
class Greeting(db.Model):
author = db.StringProperty()
email = db.EmailProperty()
class MainPage(webapp2.RequestHandler):
def get(self):
en = Greeting(author='hellooo', email=db.Email("[email protected]"))
en.put()
app = webapp2.WSGIApplication([('/', MainPage)],
debug=True)
,并得到这样
dev~devchat> x = Greeting.get_by_id(2)
dev~devchat> x.author
u'hellooo'
dev~devchat> x.email
u'[email protected]'
dev~devchat> x.email.ToXml()
u'<gd:email address="a[email protected]" />'
值