diff options
author | Matěj Cepl <mcepl@cepl.eu> | 2024-01-19 03:07:54 +0100 |
---|---|---|
committer | Matěj Cepl <mcepl@cepl.eu> | 2024-01-21 21:57:15 +0100 |
commit | b638466e6a6ada7478758cf740c89650d0f70f59 (patch) | |
tree | f34979881a12818ba46a4b74a7a7096e737e441a /libbe/util/wsgi.py | |
parent | b11b63156666589ec9749fa318fe7ecd9d1f136d (diff) | |
download | bugseverywhere-b638466e6a6ada7478758cf740c89650d0f70f59.tar.gz |
WIP plenty of clean-ups and porting to Python 3.
Diffstat (limited to 'libbe/util/wsgi.py')
-rw-r--r-- | libbe/util/wsgi.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/libbe/util/wsgi.py b/libbe/util/wsgi.py index 46e1b3c..cfa43be 100644 --- a/libbe/util/wsgi.py +++ b/libbe/util/wsgi.py @@ -24,6 +24,7 @@ See Also """ import copy +import functools import hashlib import logging import logging.handlers @@ -66,11 +67,6 @@ import libbe.util.http import libbe.util.id -# https://stackoverflow.com/a/56719588/164233 -def cmp(a, b): - return (int(a) > int(b)) - (int(a) < int(b)) - - if libbe.TESTING: import doctest import unittest @@ -95,6 +91,7 @@ class Unauthorized (HandlerError): super(Unauthorized, self).__init__(403, msg, headers) +@functools.total_ordering class User (object): def __init__(self, uname=None, name=None, passhash=None, password=None): self.uname = uname @@ -120,8 +117,11 @@ class User (object): def __str__(self): return ':'.join([self.uname, self.name, self.passhash]) - def __cmp__(self, other): - return cmp(self.uname, other.uname) + def __eq__(self, other): + return self.uname == other.uname + + def __lt__(self, other): + return self.uname < other.uname def hash(self, password): return hashlib.sha1(password).hexdigest() |