[Zope] Poll product

Chris Muldrow muldrow@mac.com
Thu, 17 May 2001 11:34:34 +0000


We had someone pinging our poll with an automated script. We didn't want
users to have to log in before voting, but still wanted some way to keep
people from hitting the vote method more than once per session. (We're using
the poll product mega modified from Amos' Poll Product) We decided to throw
a cookie at the users and check it when they go into the poll--on first
visit it lets them vote, but then it cookies them and redirects to the
results page. This is pretty straightforward for Zope addicts, but I figured
this might be useful information for someone, so here goes:

Just paste the following chunk of code at the top of the index.dtml file
that sits in the poll product:

<dtml-if "REQUEST.has_key('voted_in_poll')">
<HTML>
<HEAD>
<META HTTP-EQUIV="Refresh" CONTENT="0;URL=<dtml-var absolute_url>/results">
</HEAD>
</HTML>
</dtml-if> 
<dtml-call "RESPONSE.setCookie('voted_in_poll', '1')">