English 中文(简体)
用户:id()改为用户.email()
原标题:Converting a User.user_id() to a User.email()

鉴于用户_id,能否找到用户电子邮件?

最佳回答

似乎不可能从用户id处获得电子邮件。 如果您想从用户到电子邮件,那么,在用户挂牌时,你必须储存,然后当用户不挂在册时,就进行转换。 例如:

class Email(db.model):
     keyed by user_id   
  email=db.EmailProperty()

def save_user():
  u=users.get_current_user()
  k=db.Key.from_path( Email ,u.user_id())
  e=Email.get(k)
  if not e:
    Email(key=k, email=u.email()).put()

def get_email_from_user_id(id):
     No way to derive email without a lookup.   
  k=db.Key.from_path( Email ,id)
  return Email.get(k).email # raises exception if email is not found 
问题回答

You can build a relationship between the email and the user_id,and then retrieve it as needed. If the user is logged in you can easily access both properties separately. http://code.google.com/intl/en/appengine/docs/python/users/userclass.html

然而,用户_id不是能够使用某种算法进行重建的电子邮件的 ha版。





相关问题
How to make logging.debug work on Appengine?

I m having a tough time getting the logging on Appengine working. the statement import logging is flagged as an unrecognized import in my PyDev Appengine project. I suspected that this was just an ...

gqlQuery returns object, want list of keys

Is there a way to convert the GqlQuery object to an array of keys, or is there a way to force the query to return an array of keys? For example: items = db.GqlQuery("SELECT __key__ FROM Items") ...

Integrating Google AppEngine with a Thick Client

I want to make a multi-user client-server solution with Java Swing thick client as a front-end and Google AppEngine (Java one) as a back-end. The problem is that GAE provides only web-based forms for ...

sorl.thumbnail : thumbnail is not a valid tag library?

I am trying to install sorl.thumbnail but am getting the following error message: thumbnail is not a valid tag library: Could not load template library from django.templatetags.thumbnail, No module ...

热门标签