0

更新 0 此链接描述了 302 代码,但我无法理解技术语言。302 代码出现在模板之后self.response.out.write(但从unexpected.html不触发模板是否重要?这是我可以使用最多帮助的部分。

INFO     2012-09-24 01:15:10,182 dev_appserver.py:2967] "POST /reserve/Rogers/1 HTTP/1.1" 302 -

我担心self.response.out.write(必须使用其他代码才能访问,或者我使用条件句的结构unexpected.html存在缺陷。不过,我不希望任何人阅读我的代码的详细信息。 更新 0

更新 1 一行代码是多余的,在我的实际代码中被注释掉,已被删除。巧合的是,这是一个片面的if陈述,使事情更加混乱。 更新 1

更新 2 我已经使用下面的代码和不同的 a、b、c、d 值,并验证所有分支都按我的预期工作。所以我相信我的代码结构不是问题。我想我需要进一步研究这个self.response.out.write(过程。

a=3
b=3
c=5
d=6
if c<d:
    print "c<d"
if a<b:
    print "a<b"
elif a==b:
    print "a=b"
else:
    print "not a<=b"
print "not a b"

更新 2

此代码有一对嵌套的 for 循环,其中包含 if/elif/elif/elif/else。第一个 if 包含一个 if,而 if 又包含一个 if、一个 if/else 和一个无条件短语。为简洁起见,我省略了几行。

着眼于第 10 行开始的向下self.response.out.write(,而两条相似的行也开始向下约 7 行self.response.out.write(。这些行都应该将用户发送到一个名为模板的模板unexpected.html,建议用户在该模板中按下“确定”按钮以将其发送到某处以修复其输入中的错误。

问题是我收到 302 错误,并且处理继续到此代码下方的代码。

我的条件句有什么问题,还是什么?

for courtname in courtnames:
    for time in times:
    if name == hiddenname:
        pass
    elif name != hiddenname and hiddenname == "":
        #check early and late
        if (res-utime)<timedelta(hours=minBefore[1]):
        template_values = {'trans':trans,'location_id':location_id}
        path = os.path.join(TEMPLATE_DIR, 'unexpected.html')
        self.response.out.write(template.render(path, \
            template_values))
        if endtime.endTime<[utime.hour,utime.minute]:
        if (res-utime)>timedelta(days=1+maxBefore[0], \
            hours=maxBefore[1],maxutes=maxBefore[2]):
            template_values = {'trans':trans,'location_id':location_id}
            path = os.path.join(TEMPLATE_DIR, 'unexpected.html')
            self.response.out.write(template.render(path, \
                template_values))
        else:
        if (res-utime)>timedelta(days=maxBefore[0], \
            hours=maxBefore[1],minutes=maxBefore[2]):
            template_values = {'trans':trans,'location_id':location_id}
            path = os.path.join(TEMPLATE_DIR, 'unexpected.html')
            self.response.out.write(template.render(path, \
                template_values))
        tempres.append([time, int(year), int(intMonth), \
            int(intWeekday), name,hiddenname,court_id, \
            weekday,weekday_key,int(day),0])
    elif name != hiddenname and name!="":
        #check early and late
        conflict = True
        tempres.append([time, int(year), int(intMonth), \
            int(intWeekday), name,hiddenname,court_id, \
            weekday,weekday_key,int(day),1])
    elif hiddenname != "" and name == "":
        conflict = True
        tempres.append([time, int(year), int(intMonth), \
            int(intWeekday), name,hiddenname,court_id, \
            weekday,weekday_key,int(day),2])
    else:
        pass
4

0 回答 0