added safe encode
This commit is contained in:
parent
c251236e43
commit
fc94489220
2 changed files with 10 additions and 1 deletions
|
|
@ -1470,6 +1470,15 @@ def get_version(doctype, name, limit = None, head = False, raise_err = True):
|
|||
def ping():
|
||||
return "pong"
|
||||
|
||||
|
||||
def safe_encode(param, encoding = 'utf-8'):
|
||||
try:
|
||||
param = param.encode(encoding)
|
||||
except Exception:
|
||||
pass
|
||||
return param
|
||||
|
||||
|
||||
def safe_decode(param, encoding = 'utf-8'):
|
||||
try:
|
||||
param = param.decode(encoding)
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ def update_user_settings(doctype, user_settings, for_update=False):
|
|||
def sync_user_settings():
|
||||
'''Sync from cache to database (called asynchronously via the browser)'''
|
||||
for key, data in iteritems(frappe.cache().hgetall('_user_settings')):
|
||||
doctype, user = key.split('::')
|
||||
doctype, user = frappe.safe_encode(key).split('::') # WTF?
|
||||
frappe.db.sql('''insert into __UserSettings (user, doctype, data) values (%s, %s, %s)
|
||||
on duplicate key update data=%s''', (user, doctype, data, data))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue