larssg / gae-score-keeper

Score Keeper for Google App Engine - just playing around (live at scorekeepr.appspot.com)

This URL has Read+Write access

Lars Sehested (author)
Sat Apr 26 16:51:13 -0700 2008
commit  4b559304e4cf993ca4368a25f0f8b0dce4d46e3c
tree    cedb6813af8829ff5bf10b2ceb6689bfdff2bd9b
parent  11464edce059044f907d7f9dbff84604eb3c7359
gae-score-keeper / matches.py
100644 39 lines (31 sloc) 0.934 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import wsgiref.handlers
import os
import sys
import string
 
from google.appengine.ext import webapp
from models import *
from scorekeepr import *
 
class MatchesPage(ScoreKeeper):
def get(self):
matches = Match.gql("ORDER BY played_at DESC LIMIT 10")
 
template_values = self.default_template_values('matches')
template_values['matches'] = matches
self.render_default_template('matches', 'index', template_values)
 
def post(self):
user = users.get_current_user()
 
if user:
match = Match(
player1 = self.request.get('player1'),
player2 = self.request.get('player2'),
score1 = string.atoi(self.request.get('score1')),
score2 = string.atoi(self.request.get('score2')),
creator = user)
match.put()
 
self.redirect('/')
 
def main():
application = webapp.WSGIApplication(
[('/matches', MatchesPage)],
debug=True)
wsgiref.handlers.CGIHandler().run(application)
 
if __name__ == "__main__":
main()