-
Notifications
You must be signed in to change notification settings - Fork 0
/
handlers.py
58 lines (36 loc) · 1.12 KB
/
handlers.py
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python
#
# See LICENSE file
#
__author__ = 'pystart-gae'
"""
This file contains non-admin webapp2 rquest handlers.
"""
from base_handler import BaseRequestHandler
import logging
logging.getLogger().setLevel(logging.DEBUG)
from slack_bot import botMsg
from models import AppData
from utils import AppError
# from google.appengine.datastore.datastore_query import Cursor
class MainHandler(BaseRequestHandler):
""" non-logged in home page
"""
def get(self):
msg = self.log_access()
botMsg('%s' % msg)
return self.render_to_response('templates/index.html', {'data': None})
class DataHandler(BaseRequestHandler):
""" display some data """
def get(self):
""" /data """
self.log_access()
data = None
try:
data = AppData.get_some()
except AppError, e:
# exception already logged
self.session.add_flash('%s' % e, level='error')
except Exception, e:
self.session.add_flash('System Error: %s' % e, level='error')
self.render_to_response('templates/index.html', {'data': data})