From 1b89116bc9693d387d437bae17dd98cdfb0e3a14 Mon Sep 17 00:00:00 2001 From: David Baumgold Date: Thu, 9 Jun 2016 21:31:19 -0400 Subject: [PATCH] Document that force_auto_coercion() is required for PasswordType --- sqlalchemy_utils/types/password.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sqlalchemy_utils/types/password.py b/sqlalchemy_utils/types/password.py index 020d107..a628098 100644 --- a/sqlalchemy_utils/types/password.py +++ b/sqlalchemy_utils/types/password.py @@ -79,13 +79,14 @@ class Password(Mutable, object): class PasswordType(types.TypeDecorator, ScalarCoercible): """ PasswordType hashes passwords as they come into the database and allows - verifying them using a pythonic interface. + verifying them using a Pythonic interface. This Pythonic interface + relies on setting up automatic data type coercison using the + :func:`~sqlalchemy_utils.listeners.force_auto_coercion` function. All keyword arguments (aside from max_length) are forwarded to the construction of a `passlib.context.LazyCryptContext` object, which also supports deferred configuration via the `onload` callback. - The following usage will create a password column that will automatically hash new passwords as `pbkdf2_sha512` but still compare passwords against pre-existing `md5_crypt` hashes. As passwords are @@ -124,6 +125,9 @@ class PasswordType(types.TypeDecorator, ScalarCoercible): import flask + from sqlalchemy_utils import PasswordType, force_auto_coercion + + force_auto_coercion() class User(db.Model): __tablename__ = 'user'