针对url参数测试db密钥失败(Python)

针对url参数测试db密钥失败(Python),python,google-app-engine,Python,Google App Engine,我正在尝试设置一个电子邮件确认,其中一个链接(如下)被发送到收件人的电子邮件地址。他们点击链接,进入一个进程,该进程将获取“post_id”,并将其与参数“i”关联的用户记录中的密钥进行比较 如果它们相等,则连接url有效。我就是不能让考试顺利进行 链接= 代码 。 . 调试输出: D 2013-08-29 19:18:28.871 In email confirmation for userid 5662278724616192 I 2013-08-29 19:18:28.887 the

我正在尝试设置一个电子邮件确认,其中一个链接(如下)被发送到收件人的电子邮件地址。他们点击链接,进入一个进程,该进程将获取“post_id”,并将其与参数“i”关联的用户记录中的密钥进行比较

如果它们相等,则连接url有效。我就是不能让考试顺利进行

链接=

代码

。 .

调试输出:

D 2013-08-29 19:18:28.871 In email confirmation for userid 5662278724616192

I 2013-08-29 19:18:28.887 the userid is: MichaelClay

D 2013-08-29 19:18:28.887 The uid of the inviter is 5662278724616192

D 2013-08-29 19:18:28.887 with a length of 16

D 2013-08-29 19:18:28.887 This should match the id value from the link: 5662278724616192

D 2013-08-29 19:18:28.887 with a length of 16

D 2013-08-29 19:18:28.887 post_id wins

我正在谷歌应用程序引擎上运行Python 2.7。有什么想法吗?

您的问题将是由
uid=User造成的。by\u id\u name(linkid)
将不是一个Userid,而是一个用户对象。它的str方法意味着当你记录东西时,它看起来像一个uid,但它不是。这意味着比较将失败

您应该比较
str(uid)==linkid
,以便代码正常工作

要证明这一点,请尝试记录repr(uid)而不是str(uid)

D 2013-08-29 19:18:28.871 In email confirmation for userid 5662278724616192

I 2013-08-29 19:18:28.887 the userid is: MichaelClay

D 2013-08-29 19:18:28.887 The uid of the inviter is 5662278724616192

D 2013-08-29 19:18:28.887 with a length of 16

D 2013-08-29 19:18:28.887 This should match the id value from the link: 5662278724616192

D 2013-08-29 19:18:28.887 with a length of 16

D 2013-08-29 19:18:28.887 post_id wins