diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/security.py | 15 | ||||
-rw-r--r-- | common/utils.py | 14 |
2 files changed, 27 insertions, 2 deletions
diff --git a/common/security.py b/common/security.py new file mode 100644 index 0000000..af1e8b9 --- /dev/null +++ b/common/security.py @@ -0,0 +1,15 @@ +from passlib.context import CryptContext + + +pwd_context = CryptContext( + schemes=["pbkdf2_sha256", "des_crypt"], + default="pbkdf2_sha256", + + # vary rounds parameter randomly when creating new hashes... + all__vary_rounds=0.1, + + # set the number of rounds that should be used... + # (appropriate values may vary for different schemes, + # and the amount of time you wish it to take) + pbkdf2_sha256__default_rounds=8000, + ) diff --git a/common/utils.py b/common/utils.py index 288673e..38ad5ed 100644 --- a/common/utils.py +++ b/common/utils.py @@ -12,8 +12,18 @@ def make_where_clause(params, join_operator="AND"): try: for (column, operator) in params.items(): - condition_subphrase = " ".join(("%s", operator, ":%s")) - where_items.append(condition_subphrase % (column, column)) + condition_subphrase = "" + + if operator == "BETWEEN": + condition_subphrase = " ".join(("%s", operator, + ":%s1 AND :%s2")) + + where_items.append(condition_subphrase % (column, column, + column)) + else: + condition_subphrase = " ".join(("%s", operator, ":%s")) + + where_items.append(condition_subphrase % (column, column)) where_statement = None if len(where_items) > 1: |