def get_context(path, args=None): if args and args.source: context = args else: context = get_page_context(path) if args: context.update(args) if hasattr(frappe.local, 'request'): # for <body data-path=""> (remove leading slash) # path could be overriden in render.resolve_from_map context["path"] = frappe.local.request.path.strip('/ ') else: context["path"] = path context.canonical = frappe.utils.get_url( frappe.utils.escape_html(context.path)) context.route = context.path context = build_context(context) # set using frappe.respond_as_web_page if hasattr(frappe.local, 'response') and frappe.local.response.get('context'): context.update(frappe.local.response.context) # to be able to inspect the context dict # Use the macro "inspect" from macros.html context._context_dict = context context.developer_mode = frappe.conf.developer_mode return context
def get_context(path, args=None): if args and args.source: context = args else: context = get_page_context(path) if args: context.update(args) if hasattr(frappe.local, 'request'): # for <body data-path=""> (remove leading slash) # path could be overriden in render.resolve_from_map context["path"] = frappe.local.request.path.strip('/ ') else: context["path"] = path context.route = context.path context = build_context(context) # set using frappe.respond_as_web_page if hasattr(frappe.local, 'response') and frappe.local.response.get('context'): context.update(frappe.local.response.context) return context
def get_context(path, args=None): if args and args.source: context = args else: context = get_page_context(path) if args: context.update(args) if hasattr(frappe.local, 'request'): # for <body data-path=""> (remove leading slash) # path could be overriden in render.resolve_from_map context["path"] = frappe.local.request.path.strip('/ ') else: context["path"] = path context.route = context.path context.current_location = frappe.request.cookies.get('city_location') context.city = frappe.db.get_list("City", fields=['city_name', 'name', 'route'], filters={'is_published': 1}, order_by='city_name', limit_page_length=200) brands = frappe.db.get_list("ItemBrand", fields=['brand_name', 'name', 'route'], filters={'published': 1}, limit_page_length=10, order_by='creation') for brand in brands: category_route = frappe.db.get_list('Item Brand Category', fields='category', filters={'parent': brand.name}) brand.category_route = frappe.db.get_value( 'Category', fieldname=['route'], filters={'name': category_route[0].category}) context.brands = brands context.item_categories = frappe.db.get_all( "Category", fields=['category_name', 'route'], filters={'published': 1}, order_by="name") context = build_context(context) # set using frappe.respond_as_web_page if hasattr(frappe.local, 'response') and frappe.local.response.get('context'): context.update(frappe.local.response.context) return context
def get_context(path, args=None): context = get_page_context(path) if args: context.update(args) context = build_context(context) if hasattr(frappe.local, 'request'): # for <body data-path=""> (remove leading slash) # path could be overriden in render.resolve_from_map context["path"] = frappe.local.request.path[1:] else: context["path"] = path # set using frappe.respond_as_web_page if hasattr(frappe.local, 'response') and frappe.local.response.get('context'): context.update(frappe.local.response.context) return context
def get_context(path, args=None): if args and args.source: context = args else: context = get_page_context(path) if args: context.update(args) if hasattr(frappe.local, 'request'): # for <body data-path=""> (remove leading slash) # path could be overriden in render.resolve_from_map context["path"] = frappe.local.request.path.strip('/ ') else: context["path"] = path context.route = context.path context.current_location = frappe.request.cookies.get('city_location') context.city = frappe.db.get_list("City", fields=['city_name', 'name'], order_by="name", limit_page_length=200) context.item_categories = frappe.db.get_all( "Category", fields=['category_name', 'route'], order_by="name") context = build_context(context) # set using frappe.respond_as_web_page if hasattr(frappe.local, 'response') and frappe.local.response.get('context'): context.update(frappe.local.response.context) return context