Created
August 27, 2010 22:42
-
-
Save emilepetrone/554330 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class VoteHandler(webapp.RequestHandler): | |
def get(self): | |
#See if logged in | |
self.Session = Session() | |
if not 'userkey' in self.Session: | |
doRender( | |
self, | |
'/', | |
{'error' : 'Please login to vote'}) | |
return | |
#Get current vote total | |
key = self.request.get('url_id') | |
url = models.URL.get_by_id(int(key)) | |
url.votes = url.votes + 1 #pull current site vote total & add 1 | |
url.put(); | |
logging.info('Adding a vote') | |
#Create a new Vote object | |
newvote = models.Vote(user=self.Session['userkey'], url=url) | |
newvote.put(); | |
self.get(); | |
doRender(self, '/') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment