Poll Results View
Now all that is left for our simple poller application is the results view for
the poll, which doesn't show us anything new, we just use the "string:" TALES
expression just to show how it works.
This tutorial shows how to implement a simple polling application using Grok.
Page
13
of
14.
The view class in poll.py:
class Results(grok.View):
grok.context(Poll)
and the template poll_templates/results.pt:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:tal="http://xml.zope.org/namespaces/tal">
<body>
<h1 tal:content="context/question">Poll question</h1>
<ul>
<li tal:repeat="option context/options">
<span tal:define="votes python:context.get_response(option.label)"
tal:replace="string:${option/label} has ${votes} votes.">
</span>
</li>
</ul>
<a href="" tal:attributes="href python: view.url(context.__parent__)">
Back to polls
</a>
</body>
</html>
This completes the last user story, and the tutorial application is completed.

