Commit 51147cc9 authored by Christian Robottom's avatar Christian Robottom

Rework overzealous check when specifying realm to Database.

parent 790480c9
......@@ -46,7 +46,7 @@ class Database:
usernames to password hashes. The hashes are SHA hex digests
produced from the password string.
"""
realm = None
def __init__(self, filename, realm=None):
"""Creates a new Database
......@@ -60,11 +60,12 @@ class Database:
self._users = {}
self.filename = filename
self.load()
if self.realm and self.realm != realm:
raise ValueError, ("Specified realm %r differs from "
"database realm %r" % (realm or '', self.realm))
else:
self.realm = realm
if realm:
if self.realm and self.realm != realm:
raise ValueError, ("Specified realm %r differs from database "
"realm %r" % (realm or '', self.realm))
else:
self.realm = realm
def save(self, fd=None):
filename = self.filename
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment