From 79965e72933666438f2216e0b4bbb331a50e501a Mon Sep 17 00:00:00 2001 From: Ryan Leckey Date: Wed, 10 Jul 2013 10:37:45 -0700 Subject: [PATCH] Rename .raw to .hash --- sqlalchemy_utils/types/password.py | 8 ++++---- tests/test_password.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sqlalchemy_utils/types/password.py b/sqlalchemy_utils/types/password.py index f520a03..ca1b03c 100644 --- a/sqlalchemy_utils/types/password.py +++ b/sqlalchemy_utils/types/password.py @@ -15,18 +15,18 @@ class Password(object): def __init__(self, value, context=None): # Store the hash. - self.raw = value + self.hash = value # Save weakref of the password context (if we have one) if context is not None: self.context = weakref.proxy(context) def __eq__(self, value): - valid, new = self.context.verify_and_update(value, self.raw) + valid, new = self.context.verify_and_update(value, self.hash) if valid and new: # New hash was calculated due to various reasons; stored one # wasn't optimal, etc. - self.raw = new + self.hash = new return valid def __ne__(self, value): @@ -85,7 +85,7 @@ class PasswordType(types.TypeDecorator): def process_bind_param(self, value, dialect): if isinstance(value, Password): # Value has already been hashed. - return value.raw + return value.hash if isinstance(value, six.string_types): # Assume value has not been hashed. diff --git a/tests/test_password.py b/tests/test_password.py index 191b9c2..1786109 100644 --- a/tests/test_password.py +++ b/tests/test_password.py @@ -32,8 +32,8 @@ class TestPasswordType(TestCase): obj = self.User() obj.password = b'b' - assert obj.password.raw != 'b' - assert obj.password.raw.startswith(b'$pbkdf2-sha512$') + assert obj.password.hash != 'b' + assert obj.password.hash.startswith(b'$pbkdf2-sha512$') def test_check(self): """ @@ -65,6 +65,6 @@ class TestPasswordType(TestCase): obj = self.User() obj.password = Password(md5_crypt.encrypt('b')) - assert obj.password.raw.startswith('$1$') + assert obj.password.hash.startswith('$1$') assert obj.password == 'b' - assert obj.password.raw.startswith('$pbkdf2-sha512$') + assert obj.password.hash.startswith('$pbkdf2-sha512$')