2013-03-27 166 views
0

我正在使用谷歌数据存储和jinja2开始。我能够添加和检索字符串值,但是当我使用电子邮件属性时: 电子邮件= db.Email 并使用.email检索它,我从数据存储区获得 类'google.appengine.api.datastore_types.Email' 。 我如何获得电子邮件的价值?如何从gae数据存储中检索电子邮件?

回答

0

使用.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]" />' 
相关问题