此语句可能引发 404 错误似乎不合逻辑。有任何想法吗?
users.create_logout_url(self.request.uri)
INFO 2012-06-30 16:20:47,374 dev_appserver.py:2952] "GET /('/_ah/login?continue=http%3A//localhost%3A8082/%3FID%3DtestBSchott&action=Logout',) HTTP/1.1" 404 -
新信息如下。
key = db.Key.from_path("PQ", ID_id)
person = PQ.get(key)
if person: #person's ID DOES exist already
if user and user == person.user: #user is owner and may revise the existing page
choices = ' '.join(person.choices)
url = users.create_logout_url(self.request.uri),
template_values = {'ID_id':person.key(),
'p': person,
'choices': choices,
'url': url
}
logging.info("7 url %s" % url )
logging.info("7 template_values %s" % template_values )
path = os.path.join(TEMPLATE_DIR, 'add_person.html')
self.response.out.write(template.render(path, template_values))
我没有在上面的 template_values 中显示所有变量;只是关键的。但是从下面的日志中,您可以看到 url 的值在 template_values 中已更改为您诊断出的讨厌的元组。我的问题是为什么以及我能做什么?
INFO 2012-06-30 19:10:38,479 views.py:209] 7 url /_ah/login?continue=http%3A//localhost%3A8082/%3FID%3DtestBSchott&action=Logout
INFO 2012-06-30 19:10:38,479 views.py:210] 7 template_values {'month': 9, 'year': 2012, 'years': [2012, 2013, 2014], 'day': 3, 'url': ('/_ah/login?continue=http%3A//localhost%3A8082/%3FID%3DtestBSchott&action=Logout',), 'months': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], 'ID_id': datastore_types.Key.from_path(u'PQ', u'testBSchott', _app=u'dev~youpoll'), 'days': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31], 'choices': u'Less Same More', 'p': <models.PQ object at 0x10bd6bf10>, 'nowyear': (2012,)}
INFO 2012-06-30 19:10:38,479 views.py:212] 6 path /Users/brian/googleapps/YouPoll/templates/add_person.html