Exemplo n.º 1
0
def clear_cache(user=None, doctype=None):
    """Clear **User**, **DocType** or global cache.

	:param user: If user is given, only user cache is cleared.
	:param doctype: If doctype is given, only DocType cache is cleared."""
    import frappe.sessions
    if doctype:
        import frappe.model.meta
        frappe.model.meta.clear_cache(doctype)
        reset_metadata_version()
    elif user:
        frappe.sessions.clear_cache(user)
    else:  # everything
        from frappe import translate
        frappe.sessions.clear_cache()
        translate.clear_cache()
        reset_metadata_version()
        clear_domainification_cache()
        local.cache = {}
        local.new_doc_templates = {}

        for fn in get_hooks("clear_cache"):
            get_attr(fn)()

    local.role_permissions = {}
Exemplo n.º 2
0
def clear_cache(user=None, doctype=None):
	"""Clear **User**, **DocType** or global cache.

	:param user: If user is given, only user cache is cleared.
	:param doctype: If doctype is given, only DocType cache is cleared."""
	import frappe.cache_manager
	if doctype:
		frappe.cache_manager.clear_doctype_cache(doctype)
		reset_metadata_version()
	elif user:
		frappe.cache_manager.clear_user_cache(user)
	else: # everything
		from frappe import translate
		frappe.cache_manager.clear_user_cache()
		translate.clear_cache()
		reset_metadata_version()
		local.cache = {}
		local.new_doc_templates = {}

		for fn in get_hooks("clear_cache"):
			get_attr(fn)()

	local.role_permissions = {}
Exemplo n.º 3
0
	def on_trash(self):
		clear_cache()
Exemplo n.º 4
0
	def on_update(self):
		clear_cache()