mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-02 15:44:06 +01:00
Some XXX comments, a little update here and there relating to users always having an id.
This commit is contained in:
parent
678c012bc6
commit
1958a76897
13
src/ircdb.py
13
src/ircdb.py
@ -209,6 +209,7 @@ class IrcUser(object):
|
|||||||
"""This class holds the capabilities and authentications for a user."""
|
"""This class holds the capabilities and authentications for a user."""
|
||||||
def __init__(self, ignore=False, password='', name='',
|
def __init__(self, ignore=False, password='', name='',
|
||||||
capabilities=(), hostmasks=None, secure=False, hashed=False):
|
capabilities=(), hostmasks=None, secure=False, hashed=False):
|
||||||
|
self.id = None
|
||||||
self.auth = [] # The (time, hostmask) list of auth crap.
|
self.auth = [] # The (time, hostmask) list of auth crap.
|
||||||
self.name = name # The name of the user.
|
self.name = name # The name of the user.
|
||||||
self.ignore = ignore # A boolean deciding if the person is ignored.
|
self.ignore = ignore # A boolean deciding if the person is ignored.
|
||||||
@ -224,10 +225,13 @@ class IrcUser(object):
|
|||||||
self.hostmasks = hostmasks
|
self.hostmasks = hostmasks
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '%s(ignore=%s, password="", name=%r, hashed=%r, ' \
|
return '%s(id=%s, ignore=%s, password="", name=%r, hashed=%r, ' \
|
||||||
'capabilities=%r, hostmasks=[], secure=%r)\n' % \
|
'capabilities=%r, hostmasks=[], secure=%r)\n' % \
|
||||||
(self.__class__.__name__, self.ignore, self.name, self.hashed,
|
(self.__class__.__name__, self.id, self.ignore, self.name,
|
||||||
self.capabilities, self.secure)
|
self.hashed, self.capabilities, self.secure)
|
||||||
|
|
||||||
|
def __hash__(self):
|
||||||
|
return hash(self.id)
|
||||||
|
|
||||||
def addCapability(self, capability):
|
def addCapability(self, capability):
|
||||||
"""Gives the user the given capability."""
|
"""Gives the user the given capability."""
|
||||||
@ -708,6 +712,7 @@ class UsersDictionary(utils.IterableMap):
|
|||||||
del self._hostmaskCache[hostmask]
|
del self._hostmaskCache[hostmask]
|
||||||
del self._hostmaskCache[id]
|
del self._hostmaskCache[id]
|
||||||
|
|
||||||
|
# XXX This shouldn't require an id, since user has an id attribute.
|
||||||
def setUser(self, id, user):
|
def setUser(self, id, user):
|
||||||
"""Sets a user (given its id) to the IrcUser given it."""
|
"""Sets a user (given its id) to the IrcUser given it."""
|
||||||
assert isinstance(id, int), 'setUser takes an integer userId.'
|
assert isinstance(id, int), 'setUser takes an integer userId.'
|
||||||
@ -747,6 +752,8 @@ class UsersDictionary(utils.IterableMap):
|
|||||||
del self._hostmaskCache[id]
|
del self._hostmaskCache[id]
|
||||||
self.flush()
|
self.flush()
|
||||||
|
|
||||||
|
# XXX This shouldn't return a tuple, just the user, since user has an
|
||||||
|
# id attribute now.
|
||||||
def newUser(self):
|
def newUser(self):
|
||||||
"""Allocates a new user in the database and returns it and its id."""
|
"""Allocates a new user in the database and returns it and its id."""
|
||||||
hashed = conf.supybot.databases.users.hash()
|
hashed = conf.supybot.databases.users.hash()
|
||||||
|
Loading…
Reference in New Issue
Block a user