【发布时间】:2013-03-27 10:48:54
【问题描述】:
我开始使用 google 数据存储和 jinja2。我可以添加和检索字符串值,但是当我使用 email 属性时: 电子邮件=db.电子邮件 并使用 .email 检索它,我得到 来自数据存储区的“google.appengine.api.datastore_types.Email”类。 我如何获得电子邮件的价值?
【问题讨论】:
我开始使用 google 数据存储和 jinja2。我可以添加和检索字符串值,但是当我使用 email 属性时: 电子邮件=db.电子邮件 并使用 .email 检索它,我得到 来自数据存储区的“google.appengine.api.datastore_types.Email”类。 我如何获得电子邮件的价值?
【问题讨论】:
使用 .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("a@a.com"))
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'a@a.com'
dev~devchat> x.email.ToXml()
u'<gd:email address="a@a.com" />'
【讨论】: