[[-- Apply the parent template for title, header/footer. --]]
<spy:parent title="To-do demo" />

[[-- the Spyce form library lets us specify python functions as handlers for submit tags --]]
<f:form>

<h2>To-do lists</h2>
[[\
# turn the list of items into links for display
lists = db.todo_lists.select(order_by=db.todo_lists.c.name)
def format(todo):
  return '<a href="list-view.spy?todoid=%s">%s</a>' % (todo.list_id, todo.name)
formatted_lists = [(format(todo), todo.list_id) for todo in lists]
]]
[[ if lists:{ ]]
<f:checkboxlist name="todoid:list:int" data="formatted_lists" />
[[ }else:{ ]]
<b>(No lists created)</b>
[[ } ]]

<h2>Actions</h2>
<ul>
  [[ if lists:{ ]]
  <li>
    [[-- actions module will be automatically imported by the form handler.
			   non-Spyce-specific parameters like onclick are output unmodified. --]]
    <f:submit value="Delete checked" handler=actions.list_delete onclick="return confirm('Are you sure you want to delete these lists?')" />
  [[ } ]]
  <li>
    <f:submit value="New list" handler=actions.list_new />:
    <f:text name=name value="" />
</ul>

</f:form>