def get(): """get session boot info""" from frappe.desk.notifications import \ get_notification_info_for_boot, get_notifications from frappe.boot import get_bootinfo, get_unseen_notes from frappe.limits import get_limits, get_expiry_message bootinfo = None if not getattr(frappe.conf, 'disable_session_cache', None): # check if cache exists bootinfo = frappe.cache().hget("bootinfo", frappe.session.user) if bootinfo: bootinfo['from_cache'] = 1 bootinfo["notification_info"].update(get_notifications()) bootinfo["user"]["recent"] = json.dumps(\ frappe.cache().hget("user_recent", frappe.session.user)) if not bootinfo: # if not create it bootinfo = get_bootinfo() bootinfo["notification_info"] = get_notification_info_for_boot() frappe.cache().hset("bootinfo", frappe.session.user, bootinfo) try: frappe.cache().ping() except redis.exceptions.ConnectionError: message = _( "Redis cache server not running. Please contact Administrator / Tech support" ) if 'messages' in bootinfo: bootinfo['messages'].append(message) else: bootinfo['messages'] = [message] # check only when clear cache is done, and don't cache this if frappe.local.request: bootinfo["change_log"] = get_change_log() bootinfo["in_setup_wizard"] = not cint( frappe.db.get_single_value('System Settings', 'setup_complete')) bootinfo["is_first_startup"] = cint( frappe.db.get_single_value('System Settings', 'is_first_startup')) bootinfo["metadata_version"] = frappe.cache().get_value("metadata_version") if not bootinfo["metadata_version"]: bootinfo["metadata_version"] = frappe.reset_metadata_version() bootinfo.notes = get_unseen_notes() for hook in frappe.get_hooks("extend_bootinfo"): frappe.get_attr(hook)(bootinfo=bootinfo) bootinfo["lang"] = frappe.translate.get_user_lang() bootinfo["disable_async"] = frappe.conf.disable_async # limits bootinfo.limits = get_limits() bootinfo.expiry_message = get_expiry_message() return bootinfo
def get(): """get session boot info""" from frappe.desk.notifications import \ get_notification_info_for_boot, get_notifications from frappe.boot import get_bootinfo, get_unseen_notes from frappe.limits import get_limits, get_expiry_message bootinfo = None if not getattr(frappe.conf,'disable_session_cache', None): # check if cache exists bootinfo = frappe.cache().hget("bootinfo", frappe.session.user) if bootinfo: bootinfo['from_cache'] = 1 bootinfo["notification_info"].update(get_notifications()) bootinfo["user"]["recent"] = json.dumps(\ frappe.cache().hget("user_recent", frappe.session.user)) if not bootinfo: # if not create it bootinfo = get_bootinfo() bootinfo["notification_info"] = get_notification_info_for_boot() frappe.cache().hset("bootinfo", frappe.session.user, bootinfo) try: frappe.cache().ping() except redis.exceptions.ConnectionError: message = _("Redis cache server not running. Please contact Administrator / Tech support") if 'messages' in bootinfo: bootinfo['messages'].append(message) else: bootinfo['messages'] = [message] # check only when clear cache is done, and don't cache this if frappe.local.request: bootinfo["change_log"] = get_change_log() bootinfo["in_setup_wizard"] = not cint(frappe.db.get_single_value('System Settings', 'setup_complete')) bootinfo["is_first_startup"] = cint(frappe.db.get_single_value('System Settings', 'is_first_startup')) bootinfo["metadata_version"] = frappe.cache().get_value("metadata_version") if not bootinfo["metadata_version"]: bootinfo["metadata_version"] = frappe.reset_metadata_version() bootinfo.notes = get_unseen_notes() for hook in frappe.get_hooks("extend_bootinfo"): frappe.get_attr(hook)(bootinfo=bootinfo) bootinfo["lang"] = frappe.translate.get_user_lang() bootinfo["disable_async"] = frappe.conf.disable_async # limits bootinfo.limits = get_limits() bootinfo.expiry_message = get_expiry_message() return bootinfo
bootinfo["metadata_version"] = frappe.cache().get_value("metadata_version") if not bootinfo["metadata_version"]: bootinfo["metadata_version"] = frappe.reset_metadata_version() bootinfo.notes = get_unseen_notes() for hook in frappe.get_hooks("extend_bootinfo"): frappe.get_attr(hook)(bootinfo=bootinfo) bootinfo["lang"] = frappe.translate.get_user_lang() bootinfo["disable_async"] = frappe.conf.disable_async # limits bootinfo.limits = get_limits() bootinfo.expiry_message = get_expiry_message() return bootinfo def get_csrf_token(): if not frappe.local.session.data.csrf_token: generate_csrf_token() return frappe.local.session.data.csrf_token def generate_csrf_token(): frappe.local.session.data.csrf_token = frappe.generate_hash() frappe.local.session_obj.update(force=True) # send sid and csrf token to the user # handles the case when a user logs in again from another tab