Skip to content

Commit

Permalink
rename db.users.addUser to db.users.findUserByAttr
Browse files Browse the repository at this point in the history
  • Loading branch information
djmitche committed Sep 7, 2011
1 parent 6aa60ba commit c2e8b11
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions master/buildbot/db/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class UsDict(dict):
class UsersConnectorComponent(base.DBConnectorComponent):
# Documentation is in developer/database.rst

def addUser(self, identifier, attr_type, attr_data, _race_hook=None):
def findUserByAttr(self, identifier, attr_type, attr_data, _race_hook=None):
def thd(conn, no_recurse=False):
tbl = self.db.model.users
tbl_info = self.db.model.users_info
Expand Down Expand Up @@ -56,7 +56,7 @@ def thd(conn, no_recurse=False):
transaction.rollback()

# try it all over again, in case there was an overlapping,
# identical call to addUser, but only retry once.
# identical call to findUserByAttr, but only retry once.
if no_recurse:
raise
return thd(conn, no_recurse=True)
Expand Down
2 changes: 1 addition & 1 deletion master/buildbot/process/users/manual.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def perspective_commandline(self, op, bb_username, bb_password, ids, info):
log.msg("Unable to find uid for identifier %s"
% user)
elif op == 'add':
d = self.master.db.users.addUser(
d = self.master.db.users.findUserByAttr(
identifier=ident,
attr_type=attr,
attr_data=user[attr])
Expand Down
2 changes: 1 addition & 1 deletion master/buildbot/process/users/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def createUserObject(master, author, src=None):
log.msg("Unrecognized source argument: %s" % src)
return

d = master.db.users.addUser(identifier=usdict['identifier'],
d = master.db.users.findUserByAttr(identifier=usdict['identifier'],
attr_type=usdict['attr_type'],
attr_data=usdict['attr_data'])
wfd = defer.waitForDeferred(d)
Expand Down
2 changes: 1 addition & 1 deletion master/buildbot/status/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ def __init__(self, port, user="statusClient", passwd="clientpw"):
self.cred = (user, passwd)
p = portal.Portal(self)
c = checkers.InMemoryUsernamePasswordDatabaseDontUse()
c.addUser(user, passwd)
c.findUserByAttr(user, passwd)
p.registerChecker(c)
f = pb.PBServerFactory(p)
s = strports.service(port, f)
Expand Down
2 changes: 1 addition & 1 deletion master/buildbot/test/fake/fakedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,7 @@ def nextId(self):

# component methods

def addUser(self, identifier, attr_type, attr_data):
def findUserByAttr(self, identifier, attr_type, attr_data):
for uid in self.users_info:
attrs = self.users_info[uid]
for attr in attrs:
Expand Down
8 changes: 4 additions & 4 deletions master/buildbot/test/unit/test_db_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def tearDown(self):
# tests

def test_addUser_new(self):
d = self.db.users.addUser(identifier='soap',
d = self.db.users.findUserByAttr(identifier='soap',
attr_type='subspace_net_handle',
attr_data='Durden0924')
def check_user(uid):
Expand All @@ -101,7 +101,7 @@ def thd(conn):

def test_addUser_existing(self):
d = self.insertTestData(self.user1_rows)
d.addCallback(lambda _ : self.db.users.addUser(
d.addCallback(lambda _ : self.db.users.findUserByAttr(
identifier='soapy',
attr_type='IPv9',
attr_data='0578cc6.8db024'))
Expand Down Expand Up @@ -134,7 +134,7 @@ def race_thd(conn):
conn.execute(self.db.model.users_info.insert(),
uid=99, attr_type='subspace_net_handle',
attr_data='Durden0924')
d = self.db.users.addUser(identifier='soap',
d = self.db.users.findUserByAttr(identifier='soap',
attr_type='subspace_net_handle',
attr_data='Durden0924',
_race_hook=race_thd)
Expand All @@ -158,7 +158,7 @@ def thd(conn):

def test_addUser_existing_identifier(self):
d = self.insertTestData(self.user1_rows)
d.addCallback(lambda _ : self.db.users.addUser(
d.addCallback(lambda _ : self.db.users.findUserByAttr(
identifier='soap',
attr_type='telepathIO(tm)',
attr_data='hmm,lye'))
Expand Down
4 changes: 2 additions & 2 deletions master/docs/developer/database.rst
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ users
interfaces with Buildbot. For example, a user may be identified as
'djmitche' in Subversion, 'dustin@v.igoro.us' in Git, and 'dustin' on IRC.
To support this functionality, each user as a set of attributes, keyed by
type. The :py:meth:`addUser` method uses these attributes to match users,
type. The :py:meth:`findUserByAttr` method uses these attributes to match users,
adding a new user if no matching user is found.

Users are identified canonically by *uid*, and are represented by *usdicts* (user
Expand All @@ -717,7 +717,7 @@ users
All attributes are also included in the dictionary, keyed by type. Types
colliding with the keys above are ignored.

.. py:method:: addUser(identifier, attr_type, attr_data)
.. py:method:: findUserByAttr(identifier, attr_type, attr_data)
:param identifier: identifier to use for a new user
:param attr_type: attribute type to search for and/or add
Expand Down

0 comments on commit c2e8b11

Please sign in to comment.