3
def getCredentials(db, login):
6
res = db.query('SELECT users.nick FROM users WHERE users.login=\'' + login + '\'').dictresult()
9
cred['nick'] = res[0]['nick']
11
res = db.query('SELECT groupid FROM group_members WHERE login=\'' + login + '\'').dictresult()
12
cred['groups'] = map(lambda x: x.get('groupid'), res)
14
res = db.query('SELECT role FROM roles WHERE login=\'' + login + '\'').dictresult()
17
cred['role'] = res[0]['role']
27
db = pg.connect('tom', 'localhost', 5432, None, None, 'tom', 'sh0r3ham')
28
c = getCredentials(db, 'conway')
30
if c['role'] != 'student' or contains('2007-INFO10001-321', c['groups']):
31
print c['nick'] + ' may view files for group \'2007-INFO10001-321\'.'