2013-03-27 162 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]" />' 
相關問題