Przeglądaj źródła

chore: Raise NotImplementedError in base Database class

Methods that have to be overridden should throw NoteImplementedError.
Helps during development :')
version-14
Gavin D'souza 3 lat temu
rodzic
commit
713eaf6ac9
2 zmienionych plików z 8 dodań i 15 usunięć
  1. +4
    -4
      frappe/database/database.py
  2. +4
    -11
      frappe/utils/password.py

+ 4
- 4
frappe/database/database.py Wyświetl plik

@@ -919,13 +919,13 @@ class Database(object):
WHERE table_name = 'tab{0}' AND column_name = '{1}' '''.format(doctype, column))[0][0]

def has_index(self, table_name, index_name):
pass
raise NotImplementedError

def add_index(self, doctype, fields, index_name=None):
pass
raise NotImplementedError

def add_unique(self, doctype, fields, constraint_name=None):
pass
raise NotImplementedError

@staticmethod
def get_index_name(fields):
@@ -951,7 +951,7 @@ class Database(object):
def escape(s, percent=True):
"""Excape quotes and percent in given string."""
# implemented in specific class
pass
raise NotImplementedError

@staticmethod
def is_column_missing(e):


+ 4
- 11
frappe/utils/password.py Wyświetl plik

@@ -10,6 +10,7 @@ from cryptography.fernet import Fernet, InvalidToken
from passlib.hash import pbkdf2_sha256, mysql41
from passlib.registry import register_crypt_handler
from passlib.context import CryptContext
from pypika.terms import Values

Auth = Table("__Auth")

@@ -51,8 +52,7 @@ def get_decrypted_password(doctype, name, fieldname="password", raise_exception=
& (Auth.encrypted == 1)
)
.limit(1)
.run()
)
).run()

if result and result[0][0]:
return decrypt(result[0][0])
@@ -70,17 +70,10 @@ def set_encrypted_password(doctype, name, pwd, fieldname="password"):

# TODO: Simplify this via aliasing methods in `frappe.qb`
if frappe.db.db_type == "mariadb":
query = (
query.on_duplicate_key_update(Auth.doctype, doctype)
.on_duplicate_key_update(Auth.name, name)
.on_duplicate_key_update(Auth.fieldname, fieldname)
)
query = query.on_duplicate_key_update(Auth.password, Values(Auth.password))
elif frappe.db.db_type == "postgres":
query = (
query.on_conflict(Auth.doctype, Auth.name, Auth.fieldname)
.do_update(Auth.doctype, doctype)
.do_update(Auth.name, name)
.do_update(Auth.fieldname, fieldname)
query.on_conflict(Auth.doctype, Auth.name, Auth.fieldname).do_update(Auth.password)
)

try:


Ładowanie…
Anuluj
Zapisz