Coverage for dryxPyramid/security.py : 18%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1from builtins import zip
3def get_users_and_groups(request):
4 """
5 *Get the users and groups from the database*
6 """
7 USERS = {}
8 GROUPS = {}
9 # get the USERS and GROUPS from the database
10 sqlQuery = u"""
11 select * from webapp_users
12 """ % locals()
13 objectDataTmp = request.db.execute(sqlQuery).fetchall()
14 objectData = []
15 objectData[:] = [dict(list(zip(list(row.keys()), row)))
16 for row in objectDataTmp]
18 for row in objectData:
19 name = (row["firstname"] + "." + row["secondname"]).lower()
20 USERS[name] = row["password"]
21 GROUPS[name] = ["group:" + row["permissions"]]
23 return USERS, GROUPS
25def groupfinder(userid, request):
26 """
27 *If the userid exists in the system, it will return a sequence of group identifiers (or an empty sequence if the user isn't a member of any groups). If the userid does not exist in the system, it will return `None`.*
28 """
29 USERS, GROUPS = get_users_and_groups(request)
31 if userid in USERS:
32 return GROUPS.get(userid, [])