更新: 唯一的答案是不是幫助我。代碼在本地系統上按需運行,但在部署的Python應用程序中無法運行。這是我的一系列問題。請給這個問題一個嚴重的第二個問題。user!= users.get_current_user()
下面是一些簡化的代碼來顯示發生了什麼。當簡化代碼放入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代碼日誌和即使用戶存在和 (用戶== person.user),即如果子句沒有成功。你能告訴我爲什麼嗎?其中一個真的包含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
Moishe,產生相同的結果。但是,謝謝。其他想法?例如,它是if語句的其他部分(如果用戶)是問題嗎?順便說一句,我認爲users.get_current_user()*是用戶ID。 – zerowords 2012-07-18 00:05:38