def find_template(context, template): logging.debug("++find_template+++++++++++++++++ current_app: %s" % context.current_app) path_lst = [] def has_file(path): path_lst.append(path) if os.path.exists(path): logging.debug('+++TEMPLATE+++ %s' % path) return True else: return False if template[0] in ('\\' '/'): if has_file(os.path.join(ROOT_PATH, template[1:])): return template[1:] if has_file(os.path.join(THEME_ROOT, template[1:])): return template[1:] if has_file(os.path.join(TEMPLATE_ROOT, template[1:])): return template[1:] else: if has_file(os.path.join(TEMPLATE_ROOT, context.current_app, template)): return os.path.join(context.current_app, template) theme_base = get_theme_templates_path(context.current_app) logging.debug('++theme_base+++++ %s' % theme_base) logging.debug('+++ %s' % os.path.join(THEME_ROOT, theme_base, template)) if has_file(os.path.join(THEME_ROOT, theme_base, template)): return os.path.join(theme_base, template) raise Exception('Cannot find template: %s' % ', '.join(path_lst))
def get_extra_context(appContext): params = {} params['appContext'] = appContext params['TEMPLATES_BASE'] = get_theme_templates_path(appContext.current_app) params['THEME_STATIC'] = get_theme_static_path(appContext.current_app) return params