Skip to content

Commit

Permalink
Factor common into thd_createUsDict
Browse files Browse the repository at this point in the history
  • Loading branch information
rafalkowalski committed Mar 24, 2015
1 parent 0fdb4c7 commit 5d1150e
Showing 1 changed file with 17 additions and 26 deletions.
43 changes: 17 additions & 26 deletions master/buildbot/db/users.py
Expand Up @@ -99,26 +99,29 @@ def thd(conn):
if not users_row:
return None

# make UsDict to return
usdict = UsDict()

# gather all attr_type and attr_data entries from users_info table
q = tbl_info.select(whereclause=(tbl_info.c.uid == uid))
rows = conn.execute(q).fetchall()
for row in rows:
usdict[row.attr_type] = row.attr_data

# add the users_row data *after* the attributes in case attr_type
# matches one of these keys.
usdict['uid'] = users_row.uid
usdict['identifier'] = users_row.identifier
usdict['bb_username'] = users_row.bb_username
usdict['bb_password'] = users_row.bb_password

return usdict
return self.thd_createUsDict(users_row, rows)
d = self.db.pool.do(thd)
return d

def thd_createUsDict(self, users_row, rows):
# make UsDict to return
usdict = UsDict()
for row in rows:
usdict[row.attr_type] = row.attr_data

# add the users_row data *after* the attributes in case attr_type
# matches one of these keys.
usdict['uid'] = users_row.uid
usdict['identifier'] = users_row.identifier
usdict['bb_username'] = users_row.bb_username
usdict['bb_password'] = users_row.bb_password

return usdict

def getUserByUsername(self, username):
def thd(conn):
tbl = self.db.model.users
Expand All @@ -130,23 +133,11 @@ def thd(conn):
if not users_row:
return None

# make UsDict to return
usdict = UsDict()

# gather all attr_type and attr_data entries from users_info table
q = tbl_info.select(whereclause=(tbl_info.c.uid == users_row.uid))
rows = conn.execute(q).fetchall()
for row in rows:
usdict[row.attr_type] = row.attr_data

# add the users_row data *after* the attributes in case attr_type
# matches one of these keys.
usdict['uid'] = users_row.uid
usdict['identifier'] = users_row.identifier
usdict['bb_username'] = users_row.bb_username
usdict['bb_password'] = users_row.bb_password

return usdict
return self.thd_createUsDict(users_row, rows)
d = self.db.pool.do(thd)
return d

Expand Down

0 comments on commit 5d1150e

Please sign in to comment.