update 0
Below is my template code.
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>
update 0
This question follows from this one
I have this def post()
code.
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))
Which produces the following in the log.
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 -
And the following post code gets the output of the submit button from the previous code after the user has made a change requiring the code below.
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)
And the log produced the following for this code.
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)
Notice how in lines 208 way above, and in line 678 just above cases
has changed and now seems to be a list in a list, instead of just a list, so that now case
singular is a single list instead of a string. This causes the ERROR, I think.