更新: 尚未给出的唯一答案是没有帮助我。该代码在我的本地系统上按需要运行,但在部署的 Python 应用程序中不起作用。这对我来说是一个系列问题。请认真考虑一下这个问题。
这是一些简化的代码来显示正在发生的事情。将简化代码放入 SDK 的交互式控制台时,它总是打印出来Hello, schott.brian
,但在部署的应用程序中它就像打印出来一样no match
。那是怎么回事?
user = "schott.brian"
name = "schott.brian"
if user and user == name:
print "Hello, " + user
else:
print "no match"
这是我的代码。注意第二次if
检查if user and (user == person.user):
user = users.get_current_user()
ID_id = self.request.get("ID", None)
ID_id = ''.join(ID_id.split())
key = db.Key.from_path("PQ", ID_id)
person = PQ.get(key)
if person: #person's ID DOES exist already
logging.info("6 person %s" % person.user )
logging.info("6 key %s" % key )
logging.info("6 ID_id %s" % ID_id )
logging.info("6 user %s" % user )
if user and (user == person.user):
# never get here on gae, but works on sdk
else:
# always gets to here by mistake on gae, but works on SDKs
logging.info("7 user %s" % user )
logging.info("7 person %s" % person.user )
这是 gae 上该代码的日志,即使用户存在并且 (user == person.user),该 if 子句也不成功。你能告诉我为什么吗?两者中的一个是否真的包含 gmail.com 而另一个不包含?
2012-07-17 15:39:19.993 6 person schott.brian
I 2012-07-17 15:39:19.993 6 key ag1zfnBhcnRpY2lwb2xschMLEgJQUSILY29kZUJTY2hvdHQM
I 2012-07-17 15:39:19.993 6 ID_id codeBSchott
I 2012-07-17 15:39:19.993 6 user schott.brian
I 2012-07-17 15:39:19.993 7 user schott.brian
I 2012-07-17 15:39:19.994 7 person schott.brian