-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommunity_page.py
29 lines (24 loc) · 1.07 KB
/
community_page.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
from google.appengine.api import users
from base_handler import *
import MySQLdb
class CommunityPage(BaseHandler):
def get(self):
user = users.get_current_user()
if user:
email = user.email()
if (os.getenv('SERVER_SOFTWARE') and os.getenv('SERVER_SOFTWARE').startswith('Google App Engine/')):
db = MySQLdb.connect(unix_socket='/cloudsql/hack-the-north-1:its-not-django', db='musicsite', user='root')
else:
db = MySQLdb.connect(host='localhost', user='root', passwd="htndjango",db="musicsite")
cursor = db.cursor()
cursor.execute('SELECT community_name,community_id FROM users WHERE email = "%s" AND invite_accepted=1' % email)
template_messages={
"logout_url":users.create_logout_url('/'),
}
self.render_response('community_page.html',**template_messages)
self.response.write('<ul>')
for row in cursor:
self.response.write('<li><a href="communities/%s">%s</a></li>' % (row[1],row[0]))
self.response.write('</ul>')
else:
self.redirect(users.create_login_url(self.request.uri))