I’m trying to add some data into data dict in a session. Why?
I want that my app use a specific value selected by the user in all the pages without passing it through get method. the reason for this is i have some pages that show information based in the value selected by the user.
Example: you have two kids and when you select one of them, in all the app the results are related with the kid selected. passing this value in every page it is not a good idea.
something like frappe.session.kid_selected .
Any idea to do what i want even if it is in another way.
frappe.cache().set_value(key, value)
value = frappe.cache().get_value(key)
# or pass a generator method
def generator_func():
# do something
return value
value = frappe.cache().get_value(key, generator_func)
What do you means by Add it to cache? Where should i add the code ? in python? which python file ya? Can you give me a hint please? Thank you very much, your help is highly appreciated.
Yes, the code above is python code. The file you need to use to set the value is the file related with the page/doctype where the user will select the value to be cached.