更新0
以下は私のテンプレートコードです。
There is a potential collision in your reservation at <emph style="font-weight: bold">{{ location_id }}</emph>
<br /><br />
<form action="/unexpected" method="post" >
<input type="hidden" name="location_id" value="{{ location_id }}"></input>
<input type="hidden" name="cases" value="{{ cases|safe }}"></input>
<table border="1" cellpadding="2"
cellspacing="0" class="sortable" id="unique-id" align="center">
<thead>
<tr>
<td>Time</td>
<td>Court</td>
<td>Currently signed up</td>
<td>You could sign up this person</td>
</tr></thead>
<tbody>
{% for time in times %}
<tr>
{% for column in time %}
<td >
{{ column|safe }}
</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
<div id="inputdata">
<label>Click the "Submit" button after selecting your option(s) above. Another option is to press the browser back button and then refresh/reload the page to see the current status without taking action here.
</label>
<input type="submit" value="submit" />
</div>
</form>
更新0
私はこのdef post()
コードを持っています。
cases=[]
for res in tempres:
r = TempReservations.get_or_insert(time[2],parent=res[8], day = int(res[9]))
r.hour = res[0][0]
r.minute = res[0][1]
r.time = res[0][2]
r.name = res[4]
r.hiddenname = res[5]
r.court_id = res[6]
r.weekday = res[7]
r.weekday_key = str(res[8])
r.put()
cases.append(r.court_id+str(r.hour)+str(r.minute))
tt=r.court_id+str(r.hour)+str(r.minute)
logging.info("string: %s" % tt)
logging.info("cases: %s" % cases)
for case in cases:
logging.info("case: %s" % case)
template_values = {'times':times,'cases':cases,'location_id':location_id}
path = os.path.join(TEMPLATE_DIR, 'collisions.html')
self.response.out.write(template.render(path, template_values))
これにより、ログに次のようになります。
INFO 2012-09-19 21:46:43,064 views.py:207] string: court11730
INFO 2012-09-19 21:46:43,064 views.py:208] cases: [u'court11730']
INFO 2012-09-19 21:46:43,064 views.py:210] case: court11730
INFO 2012-09-19 21:46:43,080 dev_appserver.py:2967] "POST /read/Rogers HTTP/1.1" 200 -
そして、次の郵便番号は、ユーザーが以下のコードを必要とする変更を行った後、前のコードから送信ボタンの出力を取得します。
def post(self):
location_id=self.request.get('location_id')
cases=self.request.get_all('cases')
for case in cases:
logging.info("cases: %s " % cases)
logging.info("case: %s " % case)
logging.info("kcase: %s " % 'k'+case)
key=str(self.request.get('k'+case))
logging.info("key: %s " % key)
そして、ログはこのコードに対して次のように生成しました。
INFO 2012-09-19 21:47:47,320 views.py:678] cases: [u"[u'court11730']"]
INFO 2012-09-19 21:47:47,320 views.py:679] case: [u'court11730']
INFO 2012-09-19 21:47:47,320 views.py:680] kcase: k [u'court11730']
INFO 2012-09-19 21:47:47,320 views.py:682] key:
ERROR 2012-09-19 21:47:47,321 webapp2.py:1553] Invalid string key .
File "/Users/brian/googleapps/scheduler/views.py", line 684, in post
res = Reservations.get(key)
上記の208行目と、すぐ上の678行目cases
が変更され、単なるリストではなくリスト内のリストのように見えるため、case
単数形が文字列ではなく単一のリストになっていることに注目してください。これがエラーの原因だと思います。